In my tile-based game, I'm using a A-star algorithm, which I have not written myself but I believe should be correctly implemented.
The problem I have is that the enemy AI can get stuck so that the enemy never gets any closer to the player.
Here's an ascii example of what I mean (x = enemy, p = player, . = ground):
.... x..p .... ....
Now, if I move the player down and process turn (which moves the enemy), the pathfinder finds the the next tile to be at south... and if I move the player up again, the pathfinder finds the next tile to be at north... so the enemy never gets any closer to the player (unless there are some obstacles, or I am closer to the enemy).
I feel stupid not to be able to figure this out on my own (at least in a nice way), but here we are. Is this a common problem, or am I doing something stupid?