我发现在《吃豆人》中有很多关于幽灵AI的参考,但没有一个提到当幽灵被《吃豆人》吃掉后,眼睛是如何找到中央幽灵洞的。
在我的实现中,我实现了一个简单但糟糕的解决方案。我只是在每个角落都用硬编码标明了应该往哪个方向走。
有没有更好的/最好的解决办法?也许是适用于不同关卡设计的通用设计?
我发现在《吃豆人》中有很多关于幽灵AI的参考,但没有一个提到当幽灵被《吃豆人》吃掉后,眼睛是如何找到中央幽灵洞的。
在我的实现中,我实现了一个简单但糟糕的解决方案。我只是在每个角落都用硬编码标明了应该往哪个方向走。
有没有更好的/最好的解决办法?也许是适用于不同关卡设计的通用设计?
当前回答
最初的《吃豆人》并没有使用寻径或花哨的AI。它只是让玩家觉得游戏比实际更有深度,但实际上它是随机的。正如Ian Millington和John Funge在《ai Intelligence for Games》中所述。
Not sure if it's true or not, but it makes a lot of sense to me. Honestly, I don't see these behaviors that people are talking about. Red/Blinky for ex is not following the player at all times, as they say. Nobody seems to be consistently following the player, on purpose. The chance that they will follow you looks random to me. And it's just very tempting to see behavior in randomness, especially when the chances of getting chased are very high, with 4 enemies and very limited turning options, in a small space. At least in its initial implementation, the game was extremely simple. Check out the book, it's in one of the first chapters.
其他回答
在游戏开始前保存地图上的节点(交叉点) 当怪物死亡时,取点(坐标)并找到 节点列表中最近的节点 计算从该节点到洞的所有路径 按长度取最短路径 将该点与最近节点之间的空间长度相加 绘制并在路径上移动
享受吧!
我建议幽灵存储他从洞到吃豆人的路径。所以一旦鬼魂死了,他就可以沿着这条存储路径向相反的方向移动。
这是一个寻径问题。有关流行的算法,请参见http://wiki.gamedev.net/index.php/A*。
假设你已经有了追逐吃豆人所需的逻辑,为什么不重用它呢?只要改变目标。这似乎比尝试使用完全相同的逻辑创建一个全新的例程要少得多。
最初的《吃豆人》并没有使用寻径或花哨的AI。它只是让玩家觉得游戏比实际更有深度,但实际上它是随机的。正如Ian Millington和John Funge在《ai Intelligence for Games》中所述。
Not sure if it's true or not, but it makes a lot of sense to me. Honestly, I don't see these behaviors that people are talking about. Red/Blinky for ex is not following the player at all times, as they say. Nobody seems to be consistently following the player, on purpose. The chance that they will follow you looks random to me. And it's just very tempting to see behavior in randomness, especially when the chances of getting chased are very high, with 4 enemies and very limited turning options, in a small space. At least in its initial implementation, the game was extremely simple. Check out the book, it's in one of the first chapters.