Pathfinding Algorithm For Pacman [closed]

自作多情 提交于 2019-11-28 04:35:00
Daniel G

For path-finding, note the following

If you're talking about the ghost AI, check out the page Chad mentioned: The Pac-Man Dossier - the ghosts actually just use the euclidean distance when determining how to make it to their target tiles, which makes them very bad at finding Pac Man in some cases.

Well this depends, do you actually want to make the ghosts work like they do in Pac-Man?

Here's a description of how the ghosts' chase AI works (they each work differently). Make sure to read the above Chapter too about how they actually try to get to their target tile. That page is a wonderfully in-depth analysis of Pac-Man, interesting read.

It depends. BFS is both complete and optimal (in the sense it finds the optimal solution)

The downside? It may take a long, long, LONG time to find it! Also, depending on the ramification factor of your problem you may run out of memory fast.

If you have no performance issues, then keep BFS, but if you want to try it in a huge maze then it may take a while to get the solution.

I suggest you try A*, the best search strategy IMHO. Even if you are not having problems with BFS, A* is a nice algorithm to implement, and you will learn a lot of cool stuff.

You may want to consider the anti-object approach that the original designers of Pacman used, you can read about it here and here.

However, to answer your question, use what works! If you are getting good results from BFS, use it. Just remember to abstract the pathfinding enough that you can replace it later if you find something better.

Good luck!

BFS will always give the shortest path if no edge weights are used. If you have no need for edge weights, I would use that. You can always switch later.

strager

Related question, which probably answers your question: Path finding in a Java 2d Game?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!