Home PIC Zone Sent in Articles and Circuits New EPE Magazine Chatzone Trading Page & New PCB Service Useful Links
Downloads Digital Electronics New Science, Maths and Eng. Articles New Elektor Electronics Magazine Forum Recommended Suppliers BAEC Members
Micromouse New Electronics & Magazine Projects New Newsletter Archive New Subscribe to BAEC
E-Mail List
Recommended Electronics Books BAEC Lending Library
Micromouse - Free BASIC and Pascal Maze Solving Programmes to Download
Micromouse Logo Robot.org.uk Micromouse page. The IEE Micromouse Contest has been running since 1977.
The micromouse competition is to build a small mobile robot that can solve a standardised maze. The competition has been running for over 25 years and is popular in the UK, USA, Singapore, Japan, Taiwan, Hong Kong, Australia and elsewhere. This "maze solving" contest was designed to challenge graduate electronic engineers.

The BASIC Programming Language.
Stands for Beginners All-purpose Symbolic Instruction Code. Developed in 1963 at the Dartmouth Naval College, United States. Was all the rage in the '80's with MicroComputers like the Commodore 64 and BBC Micro.
Quick BASIC Maze Solver Programme
This is a really clever and fun maze solving programme, download it and give it a go. Any computer with Windows also has Quick BASIC installed. Not exactly electronics related but it could be used to design a computer controlled micromouse for example.

"This is a path finder / maze solver algorithm. Written in Quick BASIC. Quick BASIC has a quick, eacy implementation of an idea without worrying about de-referencing pointers and other rubbish. It takes good care of you :~)." Primary E-Mail: drko@ba3d.com ; kristian@ou.edu

The package contains four files.

The Pascal Programming Language.
Named for a famous French Mathematician, Physicist, and Philosopher (1623-62), who invented a simple mechanical calculating machine among other things. Developed in 1970 by a Standards Committee of Computer Scientist's as a structured alternative to BASIC.

Example: No GOTO Statement only Structured Loops:

  • FOR variable := start number (or set type) TO end number (or set type) DO - can also count down, or in set step e.g. 0, 2, 4...
  • REPEAT ... code ... UNTIL
  • WHILE ... code ... DO
Also has passed local variables to procedures. Also global variables, constants, and sets (e.g. ace-king, or jan-dec). I programmed it on the Apple II and Amstrad PC1512 (x2, 5.25 Inch disk drive, and 512Kbytes of RAM) PC Clone (1986-).
Maze solving Programme using Turbo Pascal Version 7.0 .
Provides Turtle graphics (that can control a line drawing Robot using commands: rotate [+/- degrees, forward x cm, and pen UP / DOWN). Can also produce image on the Computer Screen which can be moved in a similar way.
  • micromouse.pas - Main Programme: Prompts user to select maze then calls up sub-procedures to move the turtle graphic around the maze intelligently.
    • type:
        JUNCTION_RECORD = RECORD>   x: INTEGER;   y: INTEGER; back: INTEGER; end; { Record }
    • var:
      • name: STRING;
      • any_maze, new_maze: MAZE_ARRAY;
      • choice, key: CHAR;
      • loop, loop2, x_pos, y_pos, x_wall, y_wall, stack, direction, null: INTEGER;
      • is_junction: ARRAY [1..16,1..16] OF BOOLEAN;
      • junction: ARRAY [0..100] OF JUNCTION_RECORD;
      • path: ARRAY [1..50] OF INTEGER;
    • procedure:
      • move (turtle_direction: INTEGER);
      • move_and_log (turtle_direction: INTEGER);
      • goto_next_junction (junction_heading: INTEGER);
      • procedure go_back;
      • block_and_move (turtle_direction: INTEGER);
    • function:
      • goto_and_log (junction_heading: INTEGER):INTEGER;
      Functions can only return one result variable generally BOOLEAN: TRUE or FALSE. Which can be used in:
      • An IF ... Boolean Condition Selection ... THEN ... execute code ... ELSE ... execute alternative code option ...
      • REPEAT / UNTIL loop
      • DO / WHILE loop.
      Example: REPEAT ... code ... UNTIL isQuit ( ... input variables for computation ... ).

  • maze.tpu [ Turbo Pascal Unit ] - sub-library to main programme. Note box characters became garbled. Contains the following:
    • const:
      • GREEN = 1; RED = 2; ORANGE = 3;
    • type:
      • MAZE_ARRAY = ARRAY [1..33] OF STRING; - 1..16 rows plus 17 horizontal walls.
    • procedure:
      • init_chicago_maze (var name: STRING; var chicago_maze: MAZE_ARRAY);
      • init_london_maze  (var name: STRING; var chicago_maze: MAZE_ARRAY);
      • init_japan_maze    (var name: STRING; var chicago_maze: MAZE_ARRAY);
      • write_text (name: STRING);
      • draw_maze   (any_maze: MAZE_ARRAY; colour: INTEGER);
      • draw_blocks (any_maze: MAZE_ARRAY; colour: INTEGER); - where paths diverge giving multiple options, up to three N, E, S, W exits because you can't go back the way you came from.
    • function:
      • roadblock_count (x_pos, y_pos: INTEGER; any_maze: MAZE_ARRAY):INTEGER;
      • wall_count          (x_pos, y_pos: INTEGER; any_maze: MAZE_ARRAY):INTEGER;

  • Based on the IEE micromouse robot competition mazes [Institute of Electrical Engineers]:
    • London (1981)
    • Japan (1982)
    • Chicago (1986)

  • Download all files as a WinZIP file: micromouse.zip (19 kBytes)

The above improved version of the maze solver selects exits at random. But on reaching a dead end retraces it's path back to the last junction and blocks off the entrance to that dead end at the junction. Meaning eventually all dead ends are barred and the 'mouse' eventually finds the finish. In ALL cases. A stack is used to store the junctions visited. With dead end junctions being lifted off the stack when totally blocked off i.e. up to three exits with dead ends.

A previous version of this programme didn't have any AI (Artificial Intelliegence) and just picked a new direction at each juction at random. Thus it NEVER EVER reached the finish due to a "Probability Well" always draging it back to the start. Ther probability against must have been astronomical (a goggle - 10 with 100 zeros after it???). It never got nearer than halve way there.

Other Pascal Programmes:
  • money.pas Pascal Programme to convert any given sum in money to the optimal number of denominations.
  • m_to_i.pas Imperial to Metric Pascal Programme to convert any given weight (in grams) to tons, stones, and ounces.
  • rabson.pas Newton-Rabson Successive Approximation Pascal Programme to compute a square root on a calculator for example. Works by guessing the value and then homing in on it, with successively closer attempts above then below the desired number.
  • Download all files as a WinZIP file: pas_progs.zip (5 kBytes)

Micromouse Maze Picture