Money is aMAZEing


Write a Prolog agent that accumulates as much money as possible in a maze. The maze has a single opening, which serves as both entrance and exit. Two thirds of the squares of the maze (other than the entrance) are randomly initialized with money from $5 to $9, and the rest have $0. Each square is represented by a square/3 term, containing the X and Y coordinates (0,0 is at the top left), and status of the square. The status is entrance for the entrance, been_there for squares that your agent has visited, and the money (seen to be) in the square otherwise. Your agent does not know the layout of the maze in advance, and must explore the maze using its sensors.

Your program's entry point must be a clause maze/2, where the first argument is the name of the file containing the maze, and the second is an integer seed for the random money initialization.

An agent has six possible actions that it can perform:

Access to the actions and utilities is via a controller module in the file MoneyMazeController. To call a controller predicate it must be prefixed with controller:. You may not modify the controller module.

MoneyMazeSolverDeadEnd is a simple agent that walks until it reaches a dead end then beams back to the opening. Here's a sample run, with the user's keyboard input in italics:

[eclipse 1]: compile('MoneyMazeSolverDeadEnd').
MoneyMazeController compiled traceable 11780 bytes in 0.01 seconds
MoneyMazeSolverDeadEnd compiled traceable 1500 bytes in 0.01 seconds

Yes (0.01s cpu)
[eclipse 2]: maze('TestMaze1',100).
 X 0 1 2 3 4 5 6 7 8 9 0 1 2 3
Y+----------------------------+
0|*E 6 9WW 8 5 6WW 0 7 5 5WW 0|
1| 0WW 0 6 5WW 0 6 0WWWW 9WW 8|
2| 5WWWWWW 8WW 7WWWWWWWW 0WW 8|
3| 0 7 6 6 9 0 0 8 8 0 0 6WW 8|
4|WWWWWWWW 0WWWWWWWWWWWW 5WW 0|
5|WW 0 0 5 7 5 0 0 6 0 5 0 9 0|
 +----------------------------+
Current state: 0,0 $0
Current state: 0,1 $-3
Current state: 0,2 $-1
Current state: 0,3 $-4
Current state: 1,3 $0
Current state: 2,3 $3
Current state: 3,3 $6
Current state: 4,3 $12
Current state: 4,2 $17
Current state: 4,1 $19
Current state: 4,0 $24
Current state: 5,0 $26
Current state: 6,0 $29
Current state: 6,1 $26
Current state: 6,2 $30
Current state: 6,3 $27
Current state: 5,3 $24
 X 0 1 2 3 4 5 6 7 8 9 0 1 2 3
Y+----------------------------+
0|*- 6 9WW - - -WW 0 7 5 5WW 0|
1| -WW 0 6 -WW - 6 0WWWW 9WW 8|
2| -WWWWWW -WW -WWWWWWWW 0WW 8|
3| - - - - - - - 8 8 0 0 6WW 8|
4|WWWWWWWW 0WWWWWWWWWWWW 5WW 0|
5|WW 0 0 5 7 5 0 0 6 0 5 0 9 0|
 +----------------------------+
Back at the entrance with $19 

You must submit your solution files using the submit2 program:

    ~csc545/bin/submit2 csc545 MoneyMazeSolver <your file names> 
by 7am on 28th April. Your program must run under Eclipse Prolog. Your program will be assessed by testing it on five test mazes (the same as for the maze solver - the exit square gets converted to an empty square for this project) ... TestMaze1, TestMaze2, TestMaze3, TestMaze4, TestMaze5, and five other unseen mazes. The marks are distributed as follows:

It is worth 25% of the subject's assessment. Please review the policies on assessment in the administration document.