jostbr / pymaze

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

Add Support for Wall Follower Algorithm #2

Open ThomasThelen opened 6 years ago

ThomasThelen commented 6 years ago

It would be very nice to support the wall follower algorithm. We can go about this a couple of different ways.

Add another solve method.

We would rename def solve_maze to something like def solve_recursive_back and then add a new method, def solve_wall_follower.

Pros: It keeps the code simple Quick Few auxiliary changes (for example, we may need to refactor def _validate_neighbors_solve

Cons In the long run, the code may get incredibly unstructured if we support more.

Create a solver Class

Create a base class that represents a solution method.

For example,

class Solver
{
public: 
virtual MAZE solve();
}

class WallFollower : Solver
{
 MAZE solve();
}

class RecursiveBacktracer : Solver
{
   MAZE solve();
}

etc
etc

We could always create an interface to it at a later time so that users don't need to mess around with class instantiation.

Pros: Better long term support

Cons: Adds complexity Not as easy to use?

Options:

  1. Don't support the algorithm
  2. Add a new method for it
  3. Create the class system
jostbr commented 6 years ago

Thanks for all your suggestions and contributions! Yes, initially I didn't think of including more algorithms so I just had everything maze stuff in the Maze class, but yes, creating a solver class might definitely be a good way to go. Also the wall follower algorithm sounds like a good addition.

jostbr commented 6 years ago

Also, I very recently added support for a breadth-first search solver as well as a (yet not fully functioning) bidirectional depth-first solver.