So this isn't a Python question exactly, but the code is in Python, so there it is. I have a mostly-working version of pacman -- currently, one monster v. pacman -- that includes the usual features: eat the power-up, chase the blue or flashing ghosts, get points.
When a ghost dies, his eyes zip back to the central monster box, where he is reborn and goes back to chasing pacman.
Here's the problem: my ghost algorithm is pretty simple, and it occasionally gets confused.
If he gets to a 'decision point' -- two or more options -- he asks the maze to give him paths to the next decision points by going up, down, right, or left. He then chooses the one that takes him closest to pacman (if chasing), farthest from pacman (if fleeing or flashing), or closest to the monster box (if recovering from having been eaten). He also has a random chance to go the wrong way.
However, if the ghost is recovering and happens to hit just the right spot directly over the monster box, he gets locked into an oscillation. The .bmp below shows the problem: if the ghost goes right, the end-point of that path is closer to the box than if he goes left. But once he's gone right, the path that ends closest to the box is to the left ... and so on.
The oscillation isn't permanent; eventually, the 'random chance' factor above causes him to get back to the monster box. Still, the oscillation point is annoying to the point of affecting game play.
So: anyone have suggestions for smarter algorithms? I would hate to kludge it by checking for that specific point...