org.almacha.achamaze
Class PledgeAlgorithm

java.lang.Object
  extended by org.almacha.achamaze.MazeSolvingAlgorithm
      extended by org.almacha.achamaze.PledgeAlgorithm

public class PledgeAlgorithm
extends MazeSolvingAlgorithm

An implementation of the Pledge Maze Solving Algorithm. See http://en.wikipedia.org/wiki/Maze_solving_algorithm#Pledge_algorithm

Author:
almacha

Field Summary
private  boolean followingWall
           
private  Direction going
           
private  int rotation
           
 
Constructor Summary
PledgeAlgorithm(PlayerStateForMazeAlgo playerState)
           
 
Method Summary
protected  Direction decide()
          This method decides in which direction the player should go.
private  void left()
           
private  void right()
           
 
Methods inherited from class org.almacha.achamaze.MazeSolvingAlgorithm
getPlayerState, move
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

followingWall

private boolean followingWall

rotation

private int rotation

going

private Direction going
Constructor Detail

PledgeAlgorithm

public PledgeAlgorithm(PlayerStateForMazeAlgo playerState)
Method Detail

right

private void right()

left

private void left()

decide

protected Direction decide()
Description copied from class: MazeSolvingAlgorithm
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.

Specified by:
decide in class MazeSolvingAlgorithm
Returns:
the chosen direction