From afc66d3013b7d47c6c22d6a99809bc3e7d1ff0dc Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Thu, 24 Oct 2024 14:44:20 +0200 Subject: implement breadth-first search pathfinding --- docs/class-diag.puml | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) (limited to 'docs') diff --git a/docs/class-diag.puml b/docs/class-diag.puml index 2d890d5..32b7018 100644 --- a/docs/class-diag.puml +++ b/docs/class-diag.puml @@ -148,13 +148,41 @@ rectangle Group_Collisions as "Collisions" <> { rectangle Group_Pathfinding as "Pathfinding" <> { class PathfindingContext { + PathfindingContext(Museum &) + -- + - start_point : XY <<+get>> <<+set>> + - end_point : XY <<+get>> <<+set>> + + valid_point(const XY &) : bool + + update() + -- + + get_solver() : Pathfinder & + + cycle_solver() + -- + - solvers : vec> + - solver_index : size_t + - museum : Museum & } class Pathfinder <> { + Pathfinder(Museum &) + + find_between(const XY &, const XY &) < + + get_path() : const forward_list & <> + -- + + is_visited(const XY &) : bool + # set_visited(const XY &) + -- + # clear() + - visited : vec -- # museum : Museum & } class BreadthFirstPathfinder { + + find_between(const XY &, const XY &) + + get_path() : const forward_list & + -- + - find_step(const vec> &) : vec> + - solution : forward_list + - end : XY + -- + # clear() } class DijkstraPathfinder { } @@ -185,7 +213,7 @@ rectangle Group_Model as "Model" <> { class Canvas { + Canvas(Museum &) -- - + get_tile(x, y) : Tile & + + get_tile(XY) : Tile & + set_tile(TileData) -- + update() @@ -222,7 +250,7 @@ rectangle Group_Model as "Model" <> { + set_data(TileData &) + set_type(type : const string &) + update() - + get_neighbor(dx, dy) : Tile * + + get_neighbor(XY) : Tile * -- - museum : Museum & } @@ -408,11 +436,10 @@ rectangle Group_Commands as "Commands" <> { - files : vec } class StepTileCommand { - + constructor(Canvas &, pair) + + constructor(Canvas &, const XY &) -- - canvas : Canvas & - - x : unsigned int - - y : unsigned int + - tile_pos : XY } class TimeTravelCommand { + constructor(Museum &, forwards : bool) -- cgit v1.2.3