Skip to content

Library, property tests, benchmark and CI - #1

Merged
anson10 merged 6 commits into
mainfrom
refactor/library-tests-bench
Oct 8, 2026
Merged

anson10 merged 6 commits into
mainfrom
refactor/library-tests-bench

Conversation

@anson10

@anson10 anson10 commented Oct 8, 2026

Copy link
Copy Markdown
Owner

Turns the single-file SFML demo into a tested C++20 project.

  • Library (include/pathfinder, src/): weighted grid; BFS, DFS, Dijkstra, A*, greedy. search() returns the path, its cost and the expansion order, with no graphics in the loop
  • App (app/): replays recorded searches a few cells per frame, so the window never blocks. Drag editing, mud cells, perfect mazes, weighted terrain, --screenshot for reproducible images
  • Tests: 13 Catch2 property tests (~1,850 assertions) on seeded random grids. A* matches Dijkstra and never expands more, paths are valid, reachability agrees, each cell is expanded once, mazes are spanning trees. An overestimating heuristic fails them
  • Benchmark: pathfinder-bench on 501×501 grids. A* expands 11% of BFS's cells on uniform cost and gains nothing on weighted terrain
  • Build: CMake, warnings-as-errors and sanitizer options. CI on GCC and Clang plus an ASan/UBSan job
  • Clean-up: the committed .exe/.dll/.lib files are removed and gitignored

Also includes the May bug-fix commit (2f15591), which was never pushed.

The binaries are still in older commits (~7 MB of history). Removing them from history would need a force-push to main, so this PR doesn't do it.

anson10 and others added 6 commits May 4, 2026 15:33
- Crash fix: guard algorithms against missing start/end (was UB on grid[-1][-1])
- Crash fix: guard reconstructPath against broken parent chain ({-1,-1})
- Fix: horizontal grid lines no longer bleed over the UI panel (GRID_WIDTH)
- Fix: window stays responsive during visualization via sleepAndPoll()
- Fix: A* now uses shared updateVisual() instead of its own inline draw loop
- Fix: left-click on a wall now toggles it off (was silently ignored)
- Fix: maze generation clears stale Visited/Path cells first
- Fix: remove duplicate mousePos declaration (line 531 shadow)
- Fix: remove all debug cout statements (were called 60x/sec inside drawGrid)
- Improvement: selected algorithm button highlighted in blue (ButtonActive)
- Improvement: status message guides user when no start/end placed yet
- Improvement: replaced custom INFINITY hack with numeric_limits<float>::max()
- Improvement: button bounds computed from shared constants, not duplicated

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Remove the committed .exe and SFML .dll/.lib files; CMake builds everything
- Drop the duplicate font and the old screenshot
- .gitignore build trees, IDE folders and binaries
- pathfinder library: weighted grid, BFS, DFS, Dijkstra, A*, greedy; search returns path, cost and expansion order
- Expanded means closed; stale heap entries skipped; A* heuristic scaled by the minimum cost so it stays admissible
- Perfect-maze, random-wall and weighted-terrain generators, all seeded
- App replays recorded searches per frame (no blocking), drag editing, mud cells, offscreen --screenshot mode
- CMake 3.20, C++20, warnings and sanitizer options; the single-file main.cpp is gone
- Valid walks with the reported cost; agreement on reachability
- A* matches Dijkstra's cost and never expands more; BFS optimal only on uniform cost
- Each cell expanded at most once; perfect mazes are spanning trees
- pathfinder-bench: median time, cells expanded and cost vs optimum per algorithm and scenario
- CI: GCC and Clang with warnings as errors, plus an ASan/UBSan test job
- README: design, benchmark results (A* expands 11% of BFS on uniform grids, no gain on terrain), tests, build
- GCC 13 flags the conditional-expression assignment as a possible dangling pointer (-Wdangling-pointer)
- Plain if/else, same behaviour
@anson10
anson10 merged commit 444ec4e into main Oct 8, 2026
3 checks passed
@anson10
anson10 deleted the refactor/library-tests-bench branch October 8, 2026 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant