Ye Olde Blah

ShiningSource.org => General Programming Forum => Topic started by: Job on January 13, 2007, 04:24:09 pm



Title: Autonomous Character Movement in SF
Post by: Job on January 13, 2007, 04:24:09 pm
In Shining Force many of the townspeople move around autonomously in a near random fashion. This movement can't be completely random because otherwise it wouldn't make any sense.

How do you think this is implemented in Shining Force? Is it a step by step algorithm (i.e. flip a four sided coin and move the character in the appropriate direction if possible) or path based (i.e. dynamically build a randomized path and let the character follow it, then create a new path once the old one completes)?

I would prefer a step by step implementation. I guess we could assign probabilities to each of the following directions. For example, if the character just moved up, then the probability of it moving back is 0.1, and the remaining directions have a probability of 0.3 each.

Any thoughts?


Title: Re: Autonomous Character Movement in SF
Post by: Ty on January 13, 2007, 05:10:29 pm
If it wasn't path based, then I'd guess each NPC has a "zone" they can walk within. Movement would be decided randomly, but the previous direction would be noted so the character wouldn't shuffle between the same two spaces. It would also check the collision layer to stop it from bumping into the player and other NPCs (though I'm guessing zones would not overlap to save having to calculate all the collision possibilities).

I'd probably use this method in combination with a path, so NPCs can have a set route or just wander around semi-aimlessly.


Title: Re: Autonomous Character Movement in SF
Post by: Job on January 13, 2007, 08:41:07 pm
I implemented a step-by-step demo:
http://www.bloo.us/javascript/tileengine/
Watch the Cerberus. I'm not specfying a range so it moves all over the place, but once that gets added i think it'll be pretty good.


Title: Re: Autonomous Character Movement in SF
Post by: Ty on January 13, 2007, 08:45:32 pm
Nice work! Looks like I'm going to have to break out the compiler tomorrow. All these cool things are making me feel left out :(

Is it just random movement at the moment? I'm guessing you'll be adding an anchor point that will limit its full movement. I like it.


Title: Re: Autonomous Character Movement in SF
Post by: Job on January 13, 2007, 08:57:20 pm
Yeah, i give each direction 0.25 probability. Then,  after one move the direction opposite to the move gets reduced to 0.1, while the remaining get increased to 0.3, to reduce the chances of having the character reverse his direction.
I will be adding a range to limit the character's movement. An anchor point sounds like a good idea, so i would just check the distance from the anchor point, to determine if it's within the range (rather than using a rectangle).


Title: Re: Autonomous Character Movement in SF
Post by: solmyr on January 14, 2007, 12:19:34 am
This is a pretty interesting solution! I'll be trying to figure this out soon too. I think I'm also going to have an option that the character could remain the same spot, instead of always having to choose a direction to move too.


Title: Re: Autonomous Character Movement in SF
Post by: qprman on January 14, 2007, 01:45:38 am
very nice work Job.. the times i've looked thorugh the forums there dose'nt seem much you CAN'T do lol keep up the good work ;D