public class GridWorldDomain extends java.lang.Object implements DomainGenerator
setNumberOfLocationTypes(int)
method.
Setting location types may be useful if terminating "pits" and goal locations exist in the world
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.
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
|
class |
GridWorldDomain.MovementAction
Action class for movement actions in grid world.
|
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 |
ACTIONEAST
Constant for the name of the east action
|
static java.lang.String |
ACTIONNORTH
Constant for the name of the north action
|
static java.lang.String |
ACTIONSOUTH
Constant for the name of the south action
|
static java.lang.String |
ACTIONWEST
Constant for the name of the west action
|
static java.lang.String |
ATTLOCTYPE
Constant for the name of attribute for location object type
|
static java.lang.String |
ATTX
Constant for the name of the x attribute
|
static java.lang.String |
ATTY
Constant for the name of the y attribute
|
static java.lang.String |
CLASSAGENT
Constant for the name of the agent class
|
static java.lang.String |
CLASSLOCATION
Constant for the name of the location class
|
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 |
PFATLOCATION
Constant for the name of the at location propositional function
|
static java.lang.String |
PFWALLEAST
Constant for the name of the wall to east propositional function
|
static java.lang.String |
PFWALLNORTH
Constant for the name of the wall to north propositional function
|
static java.lang.String |
PFWALLSOUTH
Constant for the name of the wall to south propositional function
|
static java.lang.String |
PFWALLWEST
Constant for the name of the wall to west propositional function
|
protected double[][] |
transitionDynamics
Matrix specifying the transition dynamics in terms of movement directions.
|
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.
|
Domain |
generateDomain()
Returns a newly instanced Domain object
|
static ValueFunctionVisualizerGUI |
getGridWorldValueFunctionVisualization(java.util.List<State> states,
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
|
static State |
getOneAgentNLocationState(Domain d,
int n)
Will return a state object with a single agent object and n location objects
|
static State |
getOneAgentNoLocationState(Domain d)
Will return a state object with a single agent object and no location objects
|
static State |
getOneAgentNoLocationState(Domain d,
int ax,
int ay)
Will return a state object with a single agent object and no location objects
|
static State |
getOneAgentOneLocationState(Domain d)
Will return a state object with a single agent object and a single location object
|
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 State |
move(State s,
int xd,
int yd,
int[][] map)
Attempts to move the agent into the given position, taking into account walls and blocks
|
protected 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.
|
static void |
setAgent(State s,
int x,
int y)
Sets the first agent object in s to the specified x and y position.
|
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.
|
static void |
setLocation(State s,
int i,
int x,
int y)
Sets the i'th location object to the specified x and y position.
|
static void |
setLocation(State s,
int i,
int x,
int y,
int locType)
Sets the i'th location object to the specified x and y position and location type.
|
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 |
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 ATTX
public static final java.lang.String ATTY
public static final java.lang.String ATTLOCTYPE
public static final java.lang.String CLASSAGENT
public static final java.lang.String CLASSLOCATION
public static final java.lang.String ACTIONNORTH
public static final java.lang.String ACTIONSOUTH
public static final java.lang.String ACTIONEAST
public static final java.lang.String ACTIONWEST
public static final java.lang.String PFATLOCATION
public static final java.lang.String PFWALLNORTH
public static final java.lang.String PFWALLSOUTH
public static final java.lang.String PFWALLEAST
public static final java.lang.String PFWALLWEST
protected int width
protected int height
protected int numLocationTypes
protected int[][] map
protected double[][] transitionDynamics
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 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 Domain generateDomain()
DomainGenerator
generateDomain
in interface DomainGenerator
public static State getOneAgentNoLocationState(Domain d)
d
- the domain object that is used to specify the min/max dimensionspublic static State getOneAgentNoLocationState(Domain d, int ax, int ay)
d
- the domain object that is used to specify the min/max dimensionsax
- the starting x position of the agentay
- the starting y position of the agentpublic static State getOneAgentOneLocationState(Domain d)
d
- the domain object that is used to specify the min/max dimensionspublic static State getOneAgentNLocationState(Domain d, int n)
d
- the domain object that is used to specify the min/max dimensionsn
- the number of location objectspublic static void setAgent(State s, int x, int y)
s
- the state with the agent whose position to setx
- the x position of the agenty
- the y position of the agentpublic static void setLocation(State s, int i, int x, int y)
s
- the state with the location objecti
- specifies which location object index to setx
- the x position of the locationy
- the y position of the locationpublic static void setLocation(State s, int i, int x, int y, int locType)
s
- the state with the location objecti
- specifies which location object index to setx
- the x position of the locationy
- the y position of the locationlocType
- the location type of the locationpublic static ValueFunctionVisualizerGUI getGridWorldValueFunctionVisualization(java.util.List<State> states, 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.valueFunction
- the value Function that can return the state values.p
- the policy to renderValueFunctionVisualizerGUI
object.protected State move(State s, int xd, int yd, int[][] map)
s
- the current statexd
- the attempted new X position of the agentyd
- the attempted new Y position of the agentprotected 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
-