diff --git a/README.md b/README.md index bd4d9c6..c4207f5 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,13 @@ # Pathfinding demo +**Work in progress** + This is a demo of pathfinding on a 2D grid. It consists of 2 main parts: -* python notes and implementation +* [python](#Python) notes and implementation * jupyter notebook file * standalone python script -* C++ demo - **work in progress** +* [C++](#C++) interactive demo ## Python @@ -24,6 +26,37 @@ Alternatively (or if you want to edit the file), you can use the [Jupyeter Lab o * file should be now visible in the left sidebar. Double-click it and confirm default kernel selection * run all the cells one by one (play button on the top) or run all of at once using menu "Run -> Run All Cells" +## C++ + +Work in progress. At the moment Linux build only. + +### Build + +#### Install prerequisities + +* SDL3 +* SDL3-image +* GLEW + +e.g. on Archlinux: + +``` +pacman -S glew sdl3 sdl3_image +``` + +#### Compile + +In the [cpp](./cpp/) folder, run [make](./cpp/Makefile) + +``` +cd cpp/ +make -j $(nproc) +``` + +### Run + +Run the "pathfinding" in the [cpp](./cpp/) folder. + ## TODO - [x] python @@ -49,5 +82,29 @@ Alternatively (or if you want to edit the file), you can use the [Jupyeter Lab o - [x] add "terrain tiles" with different costs - [x] add mouse-click action - [x] add direct movement (through mouse click action, no pathfinding) - - [ ] implement pathfinding + - [x] implement pathfinding + - [x] BFS + - [x] GBFS + - [x] Dijkstra + - [ ] A* - [ ] windows build? + - [x] VS solution + - [ ] merge to master + - [ ] cmake? + - [ ] zoom + pan of the map + - [ ] maze generator? + - [ ] collisions + - [ ] multiple units + - change from single unit (player) to RTS-style multiple units + - [ ] unit selection + - selection rectangle? + - [ ] pathfinding for multiple units + - [ ] pathfinding for multiple units + - group formation, local cohesion, etc + - [ ] cpython interface + - control the game through the interpreter + - [ ] clang-format config + - [ ] git hooks? + - [ ] [gcovr](https://gcovr.com/en/stable/) + - [ ] [clang-tidy](https://clang.llvm.org/extra/clang-tidy/) + diff --git a/cpp/src/pathfindingdemo.cpp b/cpp/src/pathfindingdemo.cpp index 63d51f2..aa2b899 100644 --- a/cpp/src/pathfindingdemo.cpp +++ b/cpp/src/pathfindingdemo.cpp @@ -18,7 +18,7 @@ PathFindingDemo::PathFindingDemo(int width, int height) : { LOG_DEBUG("."); // set default pathfinder method - m_PathFinder = pathfinder::utils::create(pathfinder::PathFinderType::LINEAR, (const Map*)&m_Map); + m_PathFinder = pathfinder::utils::create(pathfinder::PathFinderType::DIJKSTRA, (const Map*)&m_Map); } PathFindingDemo::~PathFindingDemo() { LOG_DEBUG("."); } @@ -63,7 +63,7 @@ void PathFindingDemo::CreateMap() { } WorldPos PathFindingDemo::GetRandomPosition() const { - return WorldPos{0.0, 0.0}; + return WorldPos{0.0, 0.0}; // totally random! } std::optional PathFindingDemo::GetMoveTarget() {