Mouse in a Maze Program

Alyce Brady
Kalamazoo College


In this program you will implement a simulation of a mouse looking for a piece of cheese in a maze.

Problem Specification:

Design a program to simulate mice moving through a maze until they find cheese.  A mouse always starts at the starting position, and moves one unit at a time.  Your program should be able to support mice with different movement strategies.

Your program should read in a maze configuration, including the starting position and the location of the cheese (the start and end locations for the maze).  It should allow the user to run the experiment several times.  Each time, a piece of cheese is put at the end of the maze, a mouse is put at the starting location, and the mouse is allowed to move around the maze looking for the cheese.  The user should be able to choose the movement strategy for each run of the experiment.  Your program should graphically display the state of the mouse and the maze at the end of each time unit.  When a mouse finds the cheese, your program should report how many time units it took for the mouse to find the cheese.

More specific details:

Your program should have a graphical user interface with a File menu, a strategy choice menu, a start button, a panel in which the maze is graphically displayed, and a slider bar for changing the speed of the mouse movement.  (Actually, it controls the speed of the animation -- how long the program pauses to let you view the display between time steps -- rather than the speed of the mice.)

You may use the following classes or files, which have been fully or partially implemented and are available in MouseInAMaze.zip:

You will need to implement or modify the following classes:

One possible plan of attack:

You will probably find it useful to implement this program in stages (iterative development).  For example, you might:

  1. Implement the minimum amount of code that will let you compile and run a "working" (although function-less) program. (More details are below.)
  2. Implement enough of the program to read in a maze and display it. (More details are below.)
  3. Modify the program to construct a mouse and a piece of cheese and display them in the maze. (More details are below.)
  4. Display the mouse graphically or with an image (this could be done here or as your final step). (More details are below.)
  5. Implement a moving mouse. (More details are below.)

You do not have to develop the program in this way, but if you want to follow this structured approach you will find more details below.

Implementing the minimum amount of code that will let you compile and run a "working" program:

Implementing enough of the program to read in a maze and display it:

Modifying the program to construct a mouse and piece of cheese and display them in the maze:

Displaying a mouse graphically or with an image:

Implementing a moving mouse: