![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](/media/82211/7_realshadowcaster.png)
1st, your ghosts do not start in the corridors. This is easily fixable.
Just to be sure, at least one of the X and Y coordinates should be a multiple of 8 at all times. use assert so you can crash the game as soon as something goes wrong before cumulative iterations over invalid values muddle things up.
2nd, your code assumes that your ghosts are in a tile and have four neighboring tiles. That's just not the case : when they are dead center inside a tile (x%8==0 and y%8==0), then you have four neighbors, but otherwise, the ghosts are covering parts of two tiles, you have 6 or 8 neighbor tiles depending on what you count.
The question is if your ghosts have the ability to turn around during chase phase (they don't in the original arcade).
If not, the "AI" is super simple when over multiple tiles, just go forward.
the original arcade what pushing this even further : if not at a crossroad, go onwards (potentially turning at corners).
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
![](/media/67531/Sprite-0001.png)
@RealShadowCaster the ghost can't turn around, the code makes a check to see if the possible tile is not the reverse of the current direction and then don't add as a possible move to the tile array.
[Please log in to post a comment]