# How to devise an algorithm for a person being on a walk?

by gaazkam   Last Updated September 26, 2017 18:13 PM

The game is an isometric RPG. The map is tile based.

I'm creating a town for this game. And I want one of the characters to roam the town randomly, because she is on a walk with her children.

I tagged the tiles she can go on. And I created a simplistic algorithm that I, in my naiveness, thought would be enough. Here it is:

If the character is blocked out and can't move in any direction she waits 1s before checking this again. If she can move in only one of the 4 directions, she moves that direction. If there is more than one possibility: If she can go forward, she always has 50% chance of going forward; if she can go both to her left and to her right there is an equal chance she chooses either of those two directions; and finally, if she can turn back, that chance is 2x smaller than turning to her left and 2x smaller than turning to her right. So, if she can choose from all 4 directions, she will have 50% chance to go forward, 20% chance to go to her left, 20% chance to go to her right, and 10% chance to go back. Repeat the above every step.

This algorithm fails beautifully. The character mostly moves randomly in one place. If she gets on a square she almost can't leave it.

I thought the solution would be to increase the chance of her moving forward. So I made the chance to go forward 5 times bigger than doing anything else. But this proved to hardly improve things.

COuld you give me some hints, point me to the correct direction? Or at least tell me that this is not worth it and I should instead resort to giving her a predefined path? (Are there no algorithms to make a character roam a given set of walkable tiles?)

Tags :

#### Query Search

Warning: Phalcon\Cache\Backend\File::save(/home/queryxchang/public_html/apps/frontend/config/../cache/-q-14-148891-how-to-devise-an-algorithm-for-a-person-being-on-a-walk-): failed to open stream: Disk quota exceeded in /home/queryxchang/public_html/public/index.php on line 37
Cache file /home/queryxchang/public_html/apps/frontend/config/../cache/-q-14-148891-how-to-devise-an-algorithm-for-a-person-being-on-a-walk- could not be written