我正在学习与 Berkeley 的 AI 课程类似的课程,并且我正在尝试找到 Q7 的 foodHeuristic(问题可以在此处找到),但是我不允许使用 mazeDistance,因为它的实现使用 BFS,它扩展了节点。我根本不知道如何找到这样的启发式方法。我尝试过 - 曼哈顿到壁橱食物的距离,曼哈顿到最远食物的距离,加上剩余的食物量,曼哈顿到最远食物的距离+曼哈顿从最远食物到壁橱食物的距离。
媒体搜索几乎到处都有食物,那么如何才能有效地计算它呢?
没有 mazeDistance 是否有可能击败 7000?
有关于食物启发的线索吗?
我有以下代码:
while current is not problem.getStartState():
print "Current: ", current, "Start: ", problem.getStartState()
Run Code Online (Sandbox Code Playgroud)
由于某种原因,比较效果不佳,您可以在以下输出中看到:
Current: (3, 5, 0, 0, 0, 0) Start: (4, 5, 0, 0, 0, 0)
Current: (4, 5, 0, 0, 0, 0) Start: (4, 5, 0, 0, 0, 0)
Run Code Online (Sandbox Code Playgroud)
你可以看到,即使current与getStartState()相同,它也会进入while.此外 - 当它曾经是一个2字段元组(x,y)时它工作正常.
我究竟做错了什么 ?谢谢
我想玩游戏pacman.在pacman鬼魂的移动中存在问题.我怎么能移动幽灵.我使用随机方法,但它向上或向下或向左或向右移动.我想要pacman运动背后的实际理论
这是夏天,所以我想更多地教自己,所以我开始创建一个pacman游戏,但我刚开始时遇到了问题.
public class PacMan {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws IOException {
GameApp runapp = new GameApp();
runapp.run();
}
}
Run Code Online (Sandbox Code Playgroud)
类GameApp
public class GameApp {
public void run() throws IOException {
GameCanvas game = new GameCanvas();
PacPlay play = new PacPlay();
JFrame frame = new JFrame(game.getTitle());
frame.setSize(game.getWidth(), game.getHeight());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
frame.add(play);
}
}
Run Code Online (Sandbox Code Playgroud)
其他课程
public class PacPlay extends JPanel implements ActionListener , KeyListener {
int X , Y = 0 …Run Code Online (Sandbox Code Playgroud) pacman ×4
algorithm ×1
android ×1
comparison ×1
graphic ×1
heuristics ×1
java ×1
path-finding ×1
python ×1
swing ×1
tuples ×1