Commit graph

8 commits

Author SHA1 Message Date
5c48f47a0a
feat: add the algorithm to solve the maze 2024-02-15 22:34:08 +00:00
5be7f5041a
refactor: use MazePosition as an argument
- Use MazePosition as the argument for the _break_wall_r method
- Generate small mazes for tests to avoid RecursionError exceptions.
2024-02-15 16:36:18 +00:00
32696f311d
refactor: add MazeDirections and MazePositions
- Created a new enum type called MazeDirections to represent the
  directions you can make in the maze.
- Created a class called MazePosition to represent the position on the
  maze grid. It has the functionality to calculate and return adjacent
  positions.
- Used the above two additions to refactor the _break_walls_r method and
  make it a bit easier to read.
2024-02-15 14:58:51 +00:00
4d72fe8e43
fix: fixed issues with the maze generation
- Fixed the issue where during the reconfiguration of the walls of a
  cell, those that weren't being reconfigured were reset to True
  regardless of their previous configuration.
- During testing, don't run the _break_walls_r method because it will
  run into the RecursionError exception.
- Simplify the code for drawing cells and fix the redrawing wasn't
  applied properly.
2024-02-15 03:30:30 +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
6d919a99d6
fix: add errors for invalid cell creation
- Raise CellInvalidError when attempting to specify the wrong corners of
  the cell when creating it. The x and y values should always represent
  the top left and bottom right corners of the cell.
- Raise CellTooSmallError when attempting to specify a cell which is too
  small to correctly draw its central point.
2024-02-13 18:54:58 +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
70175b3afd
test: add tests for the Maze class
Add some tests to test the Maze constructor.
2024-02-13 14:21:35 +00:00