I have tried to use the piece of code to test out the A* algorithm and when I run it the values I get are wrong, can someone try and tell me if their are any gaping errors which i missed, If anyone doesn't know what the A* algorithm is, It is the algorithm used for path finding. Thanks in advanced
public int[] pathfind(int currentX, int currentY, int finalX , int finalY) { int[][] grid = new int[3][3]; int[] lowVals = new int[3]; lowVals[2] = 2000000; for (int i = 0; i < 3; ++i) { for (int s = 0; s < 3; ++s) { grid[i][s] = (finalX - currentX + (i-1) + finalY - currentY + (s-1)); if (grid[i][s] < lowVals[2]) { lowVals[0] = i; lowVals[1] = s; lowVals[2] = grid[i][s]; } } } currentX += lowVals[0] - 1; currentY += lowVals[1] - 1; System.out.println(currentX + " " + currentY); return lowVals; }