Simulation of a robot in a maze

What follows describnes a text simplified version of the proposal. You shall use a GUI in your project.

A remote controlled Robot is to explore a maze. The maze if composed of walls, and inner empty space. The maze configuration is encoded in file maze.txt as lines of 'w' characters representing walls, 'o' characters representing space outside the maze, and empty space in the maze represented by blanks. The configuration of the maze becomes known to the robot as it discovers it by looking. The robot understands the commands (letter case is irrelevant):

a.            Look, coded with an 'l', makes the robot answer with a 9-character String from the set 'w' (wall), ' ' (blank for door – empty space), or 'o' (out) depending on what is sees on the nine cells which surround it. The robot always reports as the first sight the contents of the cell in front of it and then looks around clockwise. Remoty is short-sighted, i.e. it does not see farther than one cell.

b.            Turn direction, coded 't', which causes the robot to turn 90o to the left ('L') or right ('R');

c.            Step, coded with an 's', which makes the robot go one cell in its current direction. If it cannot move, then the command has no effect.

Draw the class diagram and write Java code to simulate the discovery of the maze by the robot. The commands are given to the robot via After each command you should print a maze snapshot as known to the robot, using the same representation as the one in the input file.

Robot commands are given as one or two letters.

Example maze.txt. Robot is marked with letter R (each cell is represented by one character):



o          w                  wo

owwwwwwwww w wwwwwwwwwwwwwwww wo

ow       w w w              w wo

ow       w w w w          w w wo

ow       w w w wwwwwwwwwwww w wo

ow       w   w            w   wo



Example commands:

      l           // would return "  woooww"


      l           // would return " w w www"


      l           // would return " ww  www"


      l           // would return "  ww www"


      l           // would return "ww w www"

t R

l           // would return " w wwwww"


After these commands the part of the world known to the robot (i.e. the snapshot of the known maze) would be:



w w

w w


w w