jostbr / pymaze

A maze generator, solver and visualizer for Python
MIT License
272 stars 63 forks source link

Suggestions to cell.py #31

Closed kkaushikvarma closed 6 years ago

kkaushikvarma commented 6 years ago

I've found your project quite interesting and have been spending some time inspecting the code. In the "cell.py" file: Line 35 (is_walls_between function), could you please tell me why one has to consider both self.walls and neighbour.walls conditions. Isn't one of them a sufficient condition to check if there are walls in-between?

if self.row - neighbour.row == 1 and self.walls["top"] and neighbour.walls["bottom"]: return True elif self.row - neighbour.row == -1 and self.walls["bottom"] and neighbour.walls["top"]: return True elif self.col - neighbour.col == 1 and self.walls["left"] and neighbour.walls["right"]: return True elif self.col - neighbour.col == -1 and self.walls["right"] and neighbour.walls["left"]: return True

I might be wrong and if it is necessary to use both these conditions, am I missing any corner cases?

ThomasThelen commented 6 years ago

Nice catch, I think you're right-it looks like it's done that way in remove_walls on line 46 in the same file.

The only thing I could see it checking against is if the neighbor cell isn't above or below self. neighbor may not be the best word describing that variable.

Edit: You can probably find a couple of things that are off in the code. For example, in the quick start example I created a maze using the Maze class ctor. This breaks the facade design pattern and the manager should probably have a method to create a maze without adding it to itself. If you see anything else, post about it!