Commit graph

15 commits

Author SHA1 Message Date
1b0f044834
feat: add a side panel for user interaction
Some checks failed
test / test (pull_request) Failing after 6s
This commit adds a simple side panel to allow users to interact with the
application. The side panel allows the user to:

- Generate and regenerate mazes
- Choose between the searching algorithms
- Choose whether or not to add randomness to the algorithm
- Run and re-run the simulation
2024-02-18 08:53:36 +00:00
b4d2e1161b
feat: add the BFS search algorithm to Solver
Add the BFS algorithm to the Solver class. This method can be executed
with or without random directions enabled.
2024-02-17 03:39:24 +00:00
611935050b
refactor: DFS not DST
The searching algorithm is called Depth-First Search not DST.
2024-02-17 02:35:01 +00:00
8466500092
feat: add the Randomised DST search algorithm
Implement a variation to the DST search algorithm to the Solver class.
In this variation, the solver randomly chooses the next direction when
it reaches a fork in its path.
2024-02-17 01:37:20 +00:00
a091f0a68d
refactor: add a dedicated class for the solver
Create a separate class to represent the solver of the maze.
Additional search algorithms will be implemented here.

Additional changes:

- Add public methods to mark cells as visited and to get results of
  the visits.
- Renamed MazeDirections to MazeDirection.
- Renamed _num_cell_rows to _height.
- Renamed _num_cells_per_row to _width.
- Created a dedicated method to configure a cell's walls in the Maze
  class.
- created a dedicated public method to draw a path between two cells in
  the Maze class.
2024-02-16 23:27:09 +00:00
5c48f47a0a
feat: add the algorithm to solve the maze 2024-02-15 22:34:08 +00:00
a919c2698b
perf: reduce CPU usage whilst idle
When the Maze Solver was idle the wait_for_close() loop ran which
continuously redrew the window in an infinite while loop. This caused
the CPU usage to spike between 70%-80%. This commit removes that method
and uses the _root.mainloop() instead to keep the window visible on the
screen. With this the CPU usage has dropped to > 1% when idle.
2024-02-15 01:40:16 +00:00
d1c3ca6658
feat: add maze generation functionality
Main feature:

- Added functionality to randomly generate a maze before the solver
  solves it.

Fixes:

- Add a public method in the Cell class called wall_exists() that
  returns true if a given cell wall exists (false otherwise).

Refactors:

- Added an enum type called CellWallLabel for labelling the four cell
  walls.
- Added a draw() function in the CellWall class to reduce repeated code.
- Move the custom exceptions to errors.py

Tests:

- Add tests for the custom exceptions.

CI:

- Added a workflow for Forgejo Actions.
2024-02-14 22:50:46 +00:00
536711f808
feat: add entrance, exit to the maze.
- Add an entrance and exit to the maze. The entrance will always
  be on the top left and the exit will always be on the bottom
  right.
- Add a simple GitHub actions workflow to run the Python tests.
2024-02-13 15:52:28 +00:00
30792f25b0
feat: add the Maze class
The Maze class stored a 2-dimensional grid of Cells. When the Maze is
initialised, the Cell's are created and drawn onto the canvas.
2024-02-13 12:18:47 +00:00
45a003270a
feat: add draw_move method to Cell
Add the draw_move method to the Cell class to draw a path between the
centre of two cells.
2024-02-13 10:48:26 +00:00
a19d9260d2
refactor: add a CellWall class
Add a CellWall class to simplify the code within the Cell class.
2024-02-13 01:15:19 +00:00
7d976f2350
feat: move Cell class to separate module. 2024-02-12 23:48:41 +00:00
14c6f659ff
feat: add the Cell class
Add the Cell class to represent a grid in the maze. Each 'Cell' can
be configured to specify which walls exists for it.
2024-02-12 23:32:03 +00:00
72dad848ec
feat: run a simple graphical window
Run a simple window and draw a few lines on it.
2024-02-12 19:53:45 +00:00