Stupid Pathfinding :-(

Posted by (twitter: @caranha)
December 16th, 2012 3:19 am

So, I’ve spend almost 6 hours today trying to get the pathfinding working for my PACMAN game, fighting lots of strange code bugs (and one eclipse bug). Then, when I get everything right, I realize that the way I was approaching the problem was fundamentally wrong!

See, I was picking one of the closest pellets, and trying to find a path around the monsters to it. If there was a monster between Pac and the pellet, this algorithm won’t find another closer pellet in the other direction!

In short, whenever pacman sees a monster between him and the pellet he wants, he freezes.

The solution is to instead implement a BFS, returning when I find the first pellet available (should have seen that all along :-( ). But since I’ve spent SO much time tweaking the AI already, I will put this on the backburner, and work a bit on the sound effects (Wakka wakka wakka!), and the graphics. After I’m done with a somewhat more polished look to my game, I will concentrate on the AI again.

Here are the links, if you want to play with dumb pacman:

Tags: , , ,

Leave a Reply

You must be logged in to post a comment.

[cache: storing page]