吃豆人寻路算法 [英] Pathfinding Algorithm For Pacman

查看:244
本文介绍了吃豆人寻路算法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现《吃豆人》游戏.对于AI而言,在很多论坛上都看到过它,我正在考虑使用A *算法.但是,我通过广度优先搜索"进行了一些简单的寻路(从点a到点b,中间有一些障碍),发现它总是提供最佳路径.我猜可能是因为在像pacman这样的游戏中,它使用简单的寻路,图中没有成本的概念.那么,如果我在Bacman中使用BFS而不是A *进行寻路,就可以了吗?

解决方案

有关路径查找,请注意以下内容

如果您正在谈论幽灵AI,请查看乍得提到的页面:吃豆人档案-幽灵实际上在确定如何使其到达目标图块时仅使用了欧几里得距离,这在某些情况下使他们很难找到吃豆人. >

I wanted to implement the game Pacman. For the AI, I was thinking of using the A* algorithm, having seen it on numerous forums. However, I implemented the Breadth First Search for some simple pathfinding (going from point a to point b with certain obstacles in between) and found it gave the optimum path always. I guess it might be because in a game like pacman which uses simple pathfinding, there is no notion of costs in the graph. So, will it be OK if I use BFS instead of A* for pathfinding in Pacman?

解决方案

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.

这篇关于吃豆人寻路算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆