public class GridWorldDomain extends java.lang.Object implements DomainGenerator
 The domain is an OODomain that consists of only
 two object classes: an agent class and a location class, each of which is defined by
 and x and y position. Locations also have an attribute defining which type of location it is.
 
Walls are not considered objects. Instead walls are considered part of the transition dynamics. There are 2 types of walls supported. Walls that are more like obstacles and occupy an entire cell of the map and 1D walls. 1D walls are specified as either a horizontal wall on the north side of a cell or a vertical wall on the east side of the wall. A cell may also have a 1D north and east wall in it. The type of wall for each cell is specified by a 2D int matrix provided to the constructor. Cells in the matrix with a 0 are clear of any walls and obstacle; 1s indicate a full cell obstacle; 2s a 1D north wall; 3s a 1D east wall; and 4s indicate that the cell has both a 1D north wall and 1D east wall.
 Note that if you change the stochastic transition dynamics or the map of the domain generator *after* generating
 a domain with generateDomain(), the previously generated domain will use the settings prior to its
 generation. To use the new settings, you will need to generate a new domain object.
 
There are five propositional functions supported: atLocation(agent, location), wallToNorth(agent), wallToSouth(agent), wallToEast(agent), and wallToWest(agent).
| Modifier and Type | Class and Description | 
|---|---|
class  | 
GridWorldDomain.AtLocationPF
Propositional function for determining if the agent is at the same position as a given location object 
 | 
static class  | 
GridWorldDomain.GridWorldModel  | 
class  | 
GridWorldDomain.WallToPF
Propositional function for indicating if a wall is in a given position relative to the agent position 
 | 
| Modifier and Type | Field and Description | 
|---|---|
static java.lang.String | 
ACTION_EAST
Constant for the name of the east action 
 | 
static java.lang.String | 
ACTION_NORTH
Constant for the name of the north action 
 | 
static java.lang.String | 
ACTION_SOUTH
Constant for the name of the south action 
 | 
static java.lang.String | 
ACTION_WEST
Constant for the name of the west action 
 | 
static java.lang.String | 
CLASS_AGENT
Constant OO-MDP class name for agent 
 | 
static java.lang.String | 
CLASS_LOCATION
Constant OO-MDP class name for a location 
 | 
protected int | 
height
The height of grid world 
 | 
protected int[][] | 
map
The wall map where the first index is the x position and the second index is the y position. 
 | 
protected int | 
numLocationTypes
The number of possible location types 
 | 
static java.lang.String | 
PF_AT_LOCATION
Constant for the name of the at location propositional function 
 | 
static java.lang.String | 
PF_WALL_EAST
Constant for the name of the wall to east propositional function 
 | 
static java.lang.String | 
PF_WALL_NORTH
Constant for the name of the wall to north propositional function 
 | 
static java.lang.String | 
PF_WALL_SOUTH
Constant for the name of the wall to south propositional function 
 | 
static java.lang.String | 
PF_WALL_WEST
Constant for the name of the wall to west propositional function 
 | 
protected RewardFunction | 
rf  | 
protected TerminalFunction | 
tf  | 
protected double[][] | 
transitionDynamics
Matrix specifying the transition dynamics in terms of movement directions. 
 | 
static java.lang.String | 
VAR_TYPE
Constant for location type variable key 
 | 
static java.lang.String | 
VAR_X
Constant for x variable key 
 | 
static java.lang.String | 
VAR_Y
Constant for y variable key 
 | 
protected int | 
width
The width of the grid world 
 | 
| Constructor and Description | 
|---|
GridWorldDomain(int[][] map)
Constructs a deterministic world based on the provided map. 
 | 
GridWorldDomain(int width,
               int height)
Constructs an empty map with deterministic transitions 
 | 
| Modifier and Type | Method and Description | 
|---|---|
void | 
clearLocationOfWalls(int x,
                    int y)
Removes any obstacles or walls at the specified location. 
 | 
OOSADomain | 
generateDomain()
Returns a newly instanced Domain object 
 | 
java.util.List<PropositionalFunction> | 
generatePfs()  | 
static ValueFunctionVisualizerGUI | 
getGridWorldValueFunctionVisualization(java.util.List<State> states,
                                      int maxX,
                                      int maxY,
                                      ValueFunction valueFunction,
                                      Policy p)
Creates and returns a  
ValueFunctionVisualizerGUI
 object for a grid world. | 
int | 
getHeight()
Returns this grid world's height 
 | 
int[][] | 
getMap()
Returns a deep copy of the map being used for the domain 
 | 
RewardFunction | 
getRf()  | 
TerminalFunction | 
getTf()  | 
double[][] | 
getTransitionDynamics()  | 
int | 
getWidth()
Returns this grid world's width 
 | 
void | 
horizontal1DNorthWall(int xi,
                     int xf,
                     int y)
Creates a sequence of 1D north walls spanning the specified start and end x coordinates. 
 | 
void | 
horizontalWall(int xi,
              int xf,
              int y)
Creates a sequence of complete cell walls spanning the specified start and end x coordinates. 
 | 
static void | 
main(java.lang.String[] args)
Creates a visual explorer or terminal explorer. 
 | 
void | 
makeEmptyMap()
Makes the map empty 
 | 
protected static int[] | 
movementDirectionFromIndex(int i)
Returns the change in x and y position for a given direction number. 
 | 
void | 
set1DEastWall(int x,
             int y)
Sets a specified location to have a 1D east wall. 
 | 
void | 
set1DNorthWall(int x,
              int y)
Sets a specified location to have a 1D north wall. 
 | 
void | 
setCellWallState(int x,
                int y,
                int wallType)
Sets the map at the specified location to have the specified wall configuration. 
 | 
void | 
setDeterministicTransitionDynamics()
Will set the domain to use deterministic action transitions. 
 | 
void | 
setMap(int[][] map)
Set the map of the world. 
 | 
void | 
setMapToFourRooms()
Will set the map of the world to the classic Four Rooms map used the original options work (Sutton, R.S. 
 | 
void | 
setNumberOfLocationTypes(int numLocationTypes)
Sets the number of possible location types to which a location object can belong. 
 | 
void | 
setObstacleInCell(int x,
                 int y)
Sets a complete cell obstacle in the designated location. 
 | 
void | 
setProbSucceedTransitionDynamics(double probSucceed)
Sets the domain to use probabilistic transitions. 
 | 
void | 
setRf(RewardFunction rf)  | 
void | 
setTf(TerminalFunction tf)  | 
void | 
setTransitionDynamics(double[][] transitionDynamics)
Will set the movement direction probabilities based on the action chosen. 
 | 
void | 
vertical1DEastWall(int yi,
                  int yf,
                  int x)
Creates a sequence of 1D east walls spanning the specified start and end y coordinates. 
 | 
void | 
verticalWall(int yi,
            int yf,
            int x)
Creates a sequence of complete cell walls spanning the specified start and end y coordinates 
 | 
public static final java.lang.String VAR_X
public static final java.lang.String VAR_Y
public static final java.lang.String VAR_TYPE
public static final java.lang.String CLASS_AGENT
public static final java.lang.String CLASS_LOCATION
public static final java.lang.String ACTION_NORTH
public static final java.lang.String ACTION_SOUTH
public static final java.lang.String ACTION_EAST
public static final java.lang.String ACTION_WEST
public static final java.lang.String PF_AT_LOCATION
public static final java.lang.String PF_WALL_NORTH
public static final java.lang.String PF_WALL_SOUTH
public static final java.lang.String PF_WALL_EAST
public static final java.lang.String PF_WALL_WEST
protected int width
protected int height
protected int numLocationTypes
protected int[][] map
protected double[][] transitionDynamics
protected RewardFunction rf
protected TerminalFunction tf
public GridWorldDomain(int width,
                       int height)
width - width of the mapheight - height of the mappublic GridWorldDomain(int[][] map)
map - the first index is the x index, the second the y; 1 entries indicate a wallpublic void setNumberOfLocationTypes(int numLocationTypes)
numLocationTypes - the number of possible location types to which a location object can belong.public void setDeterministicTransitionDynamics()
public void setProbSucceedTransitionDynamics(double probSucceed)
probSucceed - probability to move the in intended directionpublic void setTransitionDynamics(double[][] transitionDynamics)
transitionDynamics - entries indicate the probability of movement in the given direction (second index) for the given action selected (first index).public double[][] getTransitionDynamics()
public void makeEmptyMap()
public void setMap(int[][] map)
map - the first index is the x index, the second the y; 1 entries indicate a wallpublic void setMapToFourRooms()
public void horizontalWall(int xi,
                           int xf,
                           int y)
xi - The starting x coordinate of the wallxf - The ending x coordinate of the wally - The y coordinate of the wallpublic void verticalWall(int yi,
                         int yf,
                         int x)
yi - The stating y coordinate of the wallyf - The ending y coordinate of the wallx - The x coordinate of the wallpublic void horizontal1DNorthWall(int xi,
                                  int xf,
                                  int y)
xi - The starting x coordinate of the wallxf - The ending x coordinate of the wally - The y coordinate of the wallpublic void vertical1DEastWall(int yi,
                               int yf,
                               int x)
yi - The stating y coordinate of the wallyf - The ending y coordinate of the wallx - The x coordinate of the wallpublic void setObstacleInCell(int x,
                              int y)
x - the x coordinate of the obstacley - the y coordinate of the obstaclepublic void set1DNorthWall(int x,
                           int y)
x - the x coordinate of the location to have the north wally - the y coordinate of the location to have the north wallpublic void set1DEastWall(int x,
                          int y)
x - the x coordinate of the location to have the east wally - the y coordinate of the location to have the east wallpublic void clearLocationOfWalls(int x,
                                 int y)
x - the x coordinate of the locationy - the y coordinate of the locationpublic void setCellWallState(int x,
                             int y,
                             int wallType)
x - the x coordinate of the locationy - the y coordinate of the locationwallType - the wall configuration for this location. 0 = no walls; 1 = complete cell wall/obstacle; 2 = 1D north wall; 3 = 1D east wall; 4 = 1D north *and* east wallpublic int[][] getMap()
public int getWidth()
public int getHeight()
public RewardFunction getRf()
public void setRf(RewardFunction rf)
public TerminalFunction getTf()
public void setTf(TerminalFunction tf)
public java.util.List<PropositionalFunction> generatePfs()
public OOSADomain generateDomain()
DomainGeneratorgenerateDomain in interface DomainGeneratorpublic static ValueFunctionVisualizerGUI getGridWorldValueFunctionVisualization(java.util.List<State> states, int maxX, int maxY, ValueFunction valueFunction, Policy p)
ValueFunctionVisualizerGUI
 object for a grid world. The value of states
 will be represented by colored cells from red (lowest value) to blue (highest value). North-south-east-west
 actions will be rendered with arrows using ArrowActionGlyph
 objects. The GUI will not be launched by default; call the
 ValueFunctionVisualizerGUI.initGUI()
 on the returned object to start it.states - the states whose value should be rendered.maxX - the maximum value in the x dimensionmaxY - the maximum value in the y dimensionvalueFunction - the value Function that can return the state values.p - the policy to renderValueFunctionVisualizerGUI object.protected static int[] movementDirectionFromIndex(int i)
i - the direction number (0,1,2,3 indicates north,south,east,west, respectively)public static void main(java.lang.String[] args)
args - command line args