GridSeek is a small, CLI, and grid (2D array) based path-finding project. It provides Dijkstra and A* algorithms for path finding. Each grid is represented by a Tile class that has movements cost in it. The Tile can be either ForestTile or SnowTile. Each subclass movement cost can be configured in global settings.
Create a build folder in your project folder:
mkdir build
cd build
Generate project files and build:
cmake ..
cmake --build .
After executing these commands, CMake will generate the GridSeek.exe file in your debug or release folder.
After a successful run, the application prints the generated map along with the computed shortest path to the target(s). The program then waits for user input via the command line.
The application uses a command binding system, where specific keys are mapped to actions during runtime.
| Key | Command | Description |
|---|---|---|
q |
Quit application | Terminates the program and closes the application |
a |
Switch to A* | Changes the pathfinding algorithm to A* |
d |
Switch to Dijkstra | Changes the pathfinding algorithm to Dijkstra |
r |
Regenerate grid | Generates a new grid/map and recomputes paths |
I used Command architecture for the input system. The reason is, why not? :) It is more scalable than a normal switch, if input statements. Additionally, the “game loop” becomes more readable.
As you can see in application run function:
Command* command = Input::get_instance().handle_input();
if (command)
command->execute();
Can handle all commands (including input commands and other commands) with only one if condition.