Micromouse Pascal Program with Run File
This is a simple maze solver program. It it based on mazes from the Micromouse competition. As the mouse does not know the maze beforehand it has to find its way by trial and error. It marks all junctions with an X and puts each one it passes on a stack. When it goes into a dead end the last few junctions are deleted from the stack and it tries another direction from the junction where it entered the deadend. This gives a reasonably fast route but I don't think it is optimal as there may be several routes from start to finish and the one it finds first may not be the fastest. Also it can get surplus loops in its final route which are easy to remove but I didn't implement this as it would have meant more work and testing.
Based on the IEE micromouse robot competition mazes. There are three files:
micromouse.exe - the run file
- the main program source code.
Some variables: is_junction: (ARRAY),
junction (ARRAY). procedures: procedure move (turtle_direction), move_and_log (turtle_direction), goto_next_junction (junction_heading), procedure go_back, block_and_move (turtle_direction); function: goto_and_log (junction_heading).
- a sub-library that holds the maze layouts and simple maze related functions.
Note box characters became garbled. Contains following procedures: init_chicago_maze (1986), init_london_maze (1981), init_japan_maze (1982), write_text, draw_maze, draw_blocks (where paths diverge giving multiple options); and functions: roadblock_count, wall_count.
I expanded this program in stages. I started by just drawing the maze on the screen, then got it so the user could move the mouse around using direction keys. Pascal has a turtle graphics thing which was designed to control robots with pens, so I used this. You just set the angle and forward distance. Then I got the mouse to go from junction to junction picking the next path at random. It never once managed to reach the center of the maze with this method. What actually happened was it sort of got a way then kept getting 'dragged' back to the start like the force of gravity, actually it was the force of probabilities evening out. As you can imagine, say 20 junctions with 2 or 3 routes = 2 to the power 20. Less than a 1 in a million chance. So I then got it to cancel routes it had tried out and it worked, then added a routine to optimise the route.