Published on

AI mouse in a maze

Authors
  • avatar
    Name
    Mike Barram
    Twitter

The Not AI mouse in a maze project was very successful at getting the virtual mouse to navigate a randomly generated maze using a fairly simple set of rules. It could solve about 99% of them. However, there were some maze designs that it got stuck on and others where it was very slow to find the correct path.

So, finally it was time to see how well my mouse could do at solving the maze using AI (the NEAT algorithm). A brief description of the code, how it works, and a video of the mouse is on Github

At this point I should mention the the amazing world of the micromouse. These are quite different, partly in being physical robots, but mainly that they first get to potter around the maze to build a map of it and then they race to solve the maze against the clock. My mouse isn't able to remember where it has been, it can only leave a trail and then use that trail to see (smell?) that it has been there recently.

If you've been over to Github, you'll see that my AI mouse doesn't seem to make use of the trail and looks to have adopted a wall following strategy:

ai_mice_gen1996

Of course it doesn't really have a strategy, it's just managed to get higher scores by consistently steering towards (but not into) a wall on one side. Perhaps, this isn't a surprise as the maze generating algorithm I've used creates simply connected mazes. These can be thought of as a tree structure, where the exit could be at any node in the tree and where you don't know where the exit node is until you reach it. A backtracking algorithm tries every branch of the tree with as little backtracking as possible nicely described in this Stack Overflow answer and wall following is essentially the same as backtracking.

Wikipedia lists a number of maze solving algorithms. Of these, Trémaux's algorithm looks interesting as a way of solving mazes that contain loops and my mouse, using its scent trail, may be able to work in a similar way. If I want to continue this series of projects, it looks like I should change the maze generating algorithm to one that creates loops. Then, do I go back to the non-AI mouse and implement Trémaux's algorithm, or do I just see if the AI mouse can make use of the scent trail and change how it steers in a way that emulates the behaviour of Trémaux's algorithm?