Posts

Showing posts from February, 2019

A* Pathfinding Algorithm Java Implementation

The A Star Class : import java.util.ArrayList; public class astar {     // grid [y-coordinate][x-coordinate]     public static void main(String[] args) {         // Map to be traversed :         int y = 5, x = 5;         node[][] grid = new node[y][x];         // Populate grid (Otherwise the grid will contain NULL values) :         // Set x and y values :         for (int i = 0; i < y; i++)             for (int j = 0; j < x; j++)                 grid[i][j] = new node(i, j);         // Add walls :         grid[1][1].setWalkable(false);         grid[2][2].setWalkable(false); ...