對於我的學校項目,我使用A *算法制作2D瓦片地圖以找到穿過障礙物的最短路徑。我用一個公式來從http://www.growingwiththeweb.com/2012/06/a-pathfinding-algorithm.html 得到下一個瓷磚啓發式得分對於獲取功能啓發式 public static int geth(int cx, int cy, int ex, int ey)
{
我目前正在試圖實現在C++中使用A * A *尋路:http://www.policyalmanac.org/games/aStarTutorial.htm 不過,對於第一個版本,我決定不包括對角線移動。 在C點的總結部分,在那裏它循環檢查當前點的鄰居: for each neighbour of the current square (above, below, left, right)
尋路問題,所以我這裏有一個序言程序,需要輸入這樣的: mazepath(X,Y,Maze,Path,Score)
mazepath(1, 1, [[ o, e, j, p, o],
[ o, j, o, o, o],
[ o, j, mt, j, o],
[ o, o, e, o, o],
[ p, o, j, mb, o]], Path, Score).