net.pakl.rl.maze
Class MazeWorld

java.lang.Object
  extended by net.pakl.rl.maze.MazeWorld
All Implemented Interfaces:
World

public class MazeWorld
extends java.lang.Object
implements World

This is a model of a 2D gridworld and supports all the functions specified in the World interface. Requires #setLength(int) and #setLillipadFrequency(double) to be called before build() is called.


Constructor Summary
MazeWorld(java.lang.String newName)
           
MazeWorld(java.lang.String newName, long randomSeed)
           
 
Method Summary
 void addTeleporter(State location, State destination)
           
 void build()
          Allows a world to be built once all necessary aspects of it have been specified.
 int distance(State state1, State state2)
           
 boolean getIsBuilt()
          Allows you to determine if the world has been built yet or not.
 java.lang.String getName()
           
 State getNewState(State oldState, Action action)
          This critical method returns the new state given an action from an old state, and in this case, simply adds state to position to simulate movement.
 int getNumberOfStates()
           
 double getPObstacle()
          Getter for property pObstacle.
 State getRandomState()
           
 int getSizeX()
           
 int getSizeY()
           
 State getStartingState()
           
 java.util.List getStateList()
          Returns a list of all the states (i.e.
 java.util.HashSet getTerminalStates()
           
 boolean isObstacle(State2D state)
           
 boolean isTerminalState(State state)
          Reports whether this particular state is a terminal state.
 void makeIntoObstacle(State2D state)
           
 void makeIntoTerminalState(State2D state)
           
 void removeAnyObstacle(State2D state)
           
 void setLengths(int x, int y)
          Allows you to specify the dimension of the FrogWorld and should be called before the call to build() (Note: in the future, an exception will be thrown if this function was not called first)
 void setPObstacle(double pObstacle)
          Setter for property pObstacle.
 java.util.Iterator stateIterator()
          Returns an object which lets you iterate over all states (positions) in the world.
 java.lang.String toText()
          Pretty-printing -- Returns a text representation of the world, attempting to justify text for display.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MazeWorld

public MazeWorld(java.lang.String newName,
                 long randomSeed)

MazeWorld

public MazeWorld(java.lang.String newName)
Method Detail

getNumberOfStates

public int getNumberOfStates()
Specified by:
getNumberOfStates in interface World

getSizeX

public int getSizeX()

getSizeY

public int getSizeY()

toText

public java.lang.String toText()
Pretty-printing -- Returns a text representation of the world, attempting to justify text for display.

Specified by:
toText in interface World

getName

public java.lang.String getName()

getIsBuilt

public boolean getIsBuilt()
Description copied from interface: World
Allows you to determine if the world has been built yet or not.

Specified by:
getIsBuilt in interface World

addTeleporter

public void addTeleporter(State location,
                          State destination)

getNewState

public State getNewState(State oldState,
                         Action action)
This critical method returns the new state given an action from an old state, and in this case, simply adds state to position to simulate movement. Note that there are no boundary conditions set up here.

Specified by:
getNewState in interface World

distance

public int distance(State state1,
                    State state2)

setLengths

public void setLengths(int x,
                       int y)
Allows you to specify the dimension of the FrogWorld and should be called before the call to build() (Note: in the future, an exception will be thrown if this function was not called first)


isTerminalState

public boolean isTerminalState(State state)
Description copied from interface: World
Reports whether this particular state is a terminal state.

Specified by:
isTerminalState in interface World

makeIntoTerminalState

public void makeIntoTerminalState(State2D state)

makeIntoObstacle

public void makeIntoObstacle(State2D state)

removeAnyObstacle

public void removeAnyObstacle(State2D state)

isObstacle

public boolean isObstacle(State2D state)

getTerminalStates

public java.util.HashSet getTerminalStates()

build

public void build()
Description copied from interface: World
Allows a world to be built once all necessary aspects of it have been specified.

Specified by:
build in interface World

stateIterator

public java.util.Iterator stateIterator()
Description copied from interface: World
Returns an object which lets you iterate over all states (positions) in the world.

Specified by:
stateIterator in interface World

getStateList

public java.util.List getStateList()
Description copied from interface: World
Returns a list of all the states (i.e. positions) in the world.

Specified by:
getStateList in interface World

getStartingState

public State getStartingState()
Specified by:
getStartingState in interface World

getPObstacle

public double getPObstacle()
Getter for property pObstacle.

Returns:
Value of property pObstacle.

setPObstacle

public void setPObstacle(double pObstacle)
Setter for property pObstacle.

Parameters:
pObstacle - New value of property pObstacle.

getRandomState

public State getRandomState()