org.almacha.achamaze
Class MazeSolvingAlgorithm

java.lang.Object
  extended by org.almacha.achamaze.MazeSolvingAlgorithm
Direct Known Subclasses:
FollowLeftWallAlgo, PledgeAlgorithm

public abstract class MazeSolvingAlgorithm
extends java.lang.Object

A class from which derive the classes that implement maze solving algorithm.

Author:
almacha

Field Summary
private  PlayerStateForMazeAlgo playerState
           
 
Constructor Summary
MazeSolvingAlgorithm(PlayerStateForMazeAlgo playerState)
           
 
Method Summary
protected abstract  Direction decide()
          This method decides in which direction the player should go.
 PlayerStateForMazeAlgo getPlayerState()
           
 void move()
          This method calls decide() to decide in which direction to go.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

playerState

private PlayerStateForMazeAlgo playerState
Constructor Detail

MazeSolvingAlgorithm

public MazeSolvingAlgorithm(PlayerStateForMazeAlgo playerState)
Method Detail

decide

protected abstract Direction decide()
This method decides in which direction the player should go. When this method is called, the player will then move in the chosen direction. So your implementation of decide() can assume that the player is moved in the direction you return. This method should never be called directly, even from derived classes, use move() instead.

Returns:
the chosen direction

move

public final void move()
                throws PlayerCannotMoveException
This method calls decide() to decide in which direction to go. Then it moves in that direction.

Throws:
PlayerCannotMoveException

getPlayerState

public PlayerStateForMazeAlgo getPlayerState()