Java specifications
This page contains part of the Maze assignment specifications, specific to Java.
The game's objective
Your task is to design and implement player, that can find path in the maze from place A to place B. Ideally, the path should be optimal (shortest possible) and the player should find it in shortest possible time.
Player specification
Player is to be implemented in MyPlayer class, in rph.labyrinth.players package. You will have to create this class yourself, you can use already existing player DummyPlayer as source of inspiration. The MyPlayer class should have the following structure:
It extends Player class.
It contains method called getName(){}, which returns player's name.
It contains findPath(int[][] map){} method, which loads the maze, starts player's algorithm and returns result in data structure called Path. If a path does not exist, the method should return null. (As fast as possible, the time is still counted)
Game configuration
File named configuration.xml is used to set the maze parameters. Most important are:
Player parameter - (MyPlayer).
Map load.
Maze window location - If, after running the code, it does not start and the code does not give you an error, there is a possibility that the window coordinates are set to different monitor. In that case, just change these values to
windowLeft=“0” windowTop=“0” windowWidth=“800” windowHeight=“600”.
GUI maze functions
GUI maze contains 3 basic components
The map of the maze - the starting square is colored red and the final is colored blue, walls are colored black.
Detailed description of configuration and player.
Control Buttons
Find Path - starts players algorithm for given map and shows you the resulting path.
Plan Next Step - server to help with stepping the player algorithm. See section Algorithm Stepping
Load Configuration - loads the current configuration from configuration.xml
Algorithm Stepping
To start algorithm stepping, use the Plan Next Step button. First of all you have to implement the stepping into the findPath method of your player. To do this do the following:
At first create Path, where you will save the individual squares.
In each step:
Delete from the map all shown paths: removeAllPaths();
Add current coordinates to Path: path.addCoordinate(coordinate);
Show path (Path) in the maze's window: addPath(path);
Wait for next press of the button: waitForNextStep();