|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectagent.State
vacworld.VacuumState
Represents a state in the vacuum world.
Field Summary | |
protected int |
agentDir
|
protected int |
agentX
|
protected int |
agentY
|
protected boolean |
bump
True if the agent just bumped into something. |
static int |
CLEAR
Constant representing a clear location. |
protected static int[][] |
defaultMap
|
static int |
DIRT
Constant representing a dirty location. |
protected static double |
DIRT_CHANCE
|
protected int |
height
Height of the map, including surrounding walls of the room. |
protected static int |
INIT_DIR
|
protected static int |
INIT_X
|
protected static int |
INIT_Y
|
protected int[][] |
map
An array that contains the locations of objects in the world. |
protected int |
numDirtyLocs
|
protected boolean |
robotOff
|
static int |
WALL
Constant representing a location with an obstacle. |
protected static double |
WALL_CHANCE
|
protected int |
width
Width of the map, including surrounding walls of the room. |
Constructor Summary | |
protected |
VacuumState()
Construct a new empty vacuum state. |
|
VacuumState(int[][] map)
Construct a new vacuum state given an array that specifies the map. |
Method Summary | |
boolean |
bumped()
Return true if the agent bumped into an obstacle on its previous move. |
void |
display()
Print an output of the state to the screen. |
void |
display(java.io.PrintStream output)
Print an output of the state to a print stream. |
int |
getAgentDir()
Return the agent's orientation. |
java.lang.String |
getAgentDirString()
Return a string the represents the agent's orientation. |
int |
getAgentX()
Return the agent's X position. |
int |
getAgentY()
Return the agent's Y position. |
static VacuumState |
getInitState()
Return the default initial state for the vacuum world. |
int |
getNumDirtyLocs()
Return the number of dirty locations in the state. |
static VacuumState |
getRandomState()
Return a random initial state for the vacuum world. |
boolean |
hasDirt(int x,
int y)
Return true if the specified location has dirt in it. |
boolean |
hasObstacle(int x,
int y)
Return true if the specified location has an obstacle in it. |
boolean |
inBounds(int x,
int y)
Return true if the location is within bounds of the state's map. |
boolean |
isRobotOff()
Return true if the robot is turned off in the state. |
void |
removeDirt(int x,
int y)
Remove dirt from the specified location. |
void |
setAgentDir(int dir)
Change the agent's orientation. |
void |
setAgentX(int x)
Change the agent's X position. |
void |
setAgentY(int y)
Change the agent's Y position. |
void |
setBump(boolean bump)
Set an indicator that the robot bumped into an obstacle during its previous move. |
void |
setRobotOff(boolean off)
Set an indicator that the robot has shut down in the state. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static int INIT_X
protected static int INIT_Y
protected static int INIT_DIR
public static final int CLEAR
public static final int DIRT
public static final int WALL
protected static int[][] defaultMap
protected static double DIRT_CHANCE
protected static double WALL_CHANCE
protected int agentX
protected int agentY
protected int agentDir
protected boolean robotOff
protected boolean bump
protected int[][] map
protected int numDirtyLocs
protected int height
protected int width
Constructor Detail |
protected VacuumState()
public VacuumState(int[][] map)
Method Detail |
public static VacuumState getInitState()
public static VacuumState getRandomState()
public int getAgentX()
public int getAgentY()
public int getAgentDir()
public java.lang.String getAgentDirString()
public void setAgentX(int x)
public void setAgentY(int y)
public void setAgentDir(int dir)
public void setRobotOff(boolean off)
public void setBump(boolean bump)
public void removeDirt(int x, int y)
public boolean hasDirt(int x, int y)
public boolean hasObstacle(int x, int y)
public boolean bumped()
public boolean inBounds(int x, int y)
public boolean isRobotOff()
public int getNumDirtyLocs()
public void display(java.io.PrintStream output)
public void display()
display
in class State
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |