吃豆子:眼睛如何找到回到怪物洞的路? [英] Pacman: how do the eyes find their way back to the monster hole?

查看:116
本文介绍了吃豆子:眼睛如何找到回到怪物洞的路?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Pacman中找到了很多关于鬼魂AI的参考文献,但是没有人提到在Pacman吃掉鬼魂之后眼睛如何回到中央鬼魂洞.

I found a lot of references to the AI of the ghosts in Pacman, but none of them mentioned how the eyes find their way back to the central ghost hole after a ghost is eaten by Pacman.

在我的实现中,我实现了一个简单但糟糕的解决方案.我只是在每个角落硬编码了应该采取的方向.

In my implementation I implemented a simple but awful solution. I just hard coded on every corner which direction should be taken.

有没有更好/或最好的解决方案?也许是适用于不同级别设计的通用产品?

Are there any better/or the best solution? Maybe a generic one that works with different level designs?

推荐答案

实际上,我想说您的方法是一个非常棒的解决方案,与任何寻路方法相比,运行时间成本几乎为零.

Actually, I'd say your approach is a pretty awesome solution, with almost zero-run time cost compared to any sort of pathfinding.

如果您需要将其推广到任意地图,则可以使用任何寻路算法-例如,广度优先搜索易于实现-并在游戏开始前使用该算法来计算在每个角上要编码的方向运行.

If you need it to generalise to arbitrary maps, you could use any pathfinding algorithm - breadth-first search is simple to implement, for example - and use that to calculate which directions to encode at each of the corners, before the game is run.

编辑(2010年8月11日):我刚刚被转到Pacman系统上非常详细的页面:

EDIT (11th August 2010): I was just referred to a very detailed page on the Pacman system: The Pac-Man Dossier, and since I have the accepted answer here, I felt I should update it. The article doesn't seem to cover the act of returning to the monster house explicitly but it states that the direct pathfinding in Pac-Man is a case of the following:

  • 继续朝下一个交叉路口行驶(尽管这在本质上是一种特殊情况,例如当给出选择时,选择不涉及反转方向的方向,如下一步所示);
  • 在相交处,查看相邻的出口正方形,除了您刚来自的出口正方形;
  • 选择距离目标最近的一个.如果多个目标同样接近目标,请按以下顺序选择第一个有效方向:上,左,下,右.

这篇关于吃豆子:眼睛如何找到回到怪物洞的路?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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