|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object ai.worlds.Environment ai.worlds.GridEnvironment
An environment with a two-dimensional grid layout occupied by objects.
Nested Class Summary | |
class |
GridEnvironment.GridCanvas
|
Field Summary | |
GridEnvironment.GridCanvas |
canvas
The grid display. |
static Location |
DOWN
|
java.lang.Object[][] |
grid
The grid of cells. |
static Location |
LEFT
|
static Location |
RIGHT
|
Location |
size
The size of the grid. |
Location |
start
The starting location. |
static Location |
UP
|
boolean[][] |
visited
Indicates whether a cell has been visited or not. |
Fields inherited from class ai.worlds.Environment |
agents, display, maxSteps, runner, step |
Constructor Summary | |
GridEnvironment(Agent[] a,
int xsize,
int ysize,
javax.swing.JFrame f)
|
Method Summary | |
void |
addObj(Location loc,
Obj ob)
Add an object to the grid. |
java.lang.Object |
clone()
|
boolean |
contains(java.util.Vector v,
java.lang.Class c)
Determine if vector contains an instance of given class. |
static void |
copyGrid(GridEnvironment from,
GridEnvironment to,
int xsize,
int ysize)
|
void |
fillGrid(double prob,
java.lang.Class c)
Fill grid with objects. |
void |
fillLoc(Location loc,
java.lang.Class c)
|
void |
forward(AgentBody body)
Move the agent forward. |
Obj |
getItem(java.util.Vector v,
java.lang.Class c)
Return the first instance of a class in a Vector. |
void |
grab(AgentBody body)
Grab a "grabable" object at the current location. |
boolean |
neighbor(Location loc,
java.lang.Class c)
Determine whether a class object is in a neighboring cell. |
void |
removeObj(Location loc,
Obj ob)
Remove object from grid. |
void |
snapshot()
Paint a snapshot of the environment onto the canvas and update fields in the gridPanel. |
boolean |
termination()
Terminate if all agents are dead. |
void |
turn(AgentBody body,
java.lang.String direction)
Turn the agent either left or right. |
void |
updateEnv()
Turn off all bump flags and execute the agent actions. |
Methods inherited from class ai.worlds.Environment |
displayEnv, executeAgentActions, getPercept, legalAction, performanceMeasure, run, start, stop, takeStep |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final Location LEFT
public static final Location RIGHT
public static final Location UP
public static final Location DOWN
public Location size
public java.lang.Object[][] grid
public boolean[][] visited
public Location start
public GridEnvironment.GridCanvas canvas
Constructor Detail |
public GridEnvironment(Agent[] a, int xsize, int ysize, javax.swing.JFrame f)
Method Detail |
public java.lang.Object clone()
public void forward(AgentBody body)
body
- is the agent body.public void turn(AgentBody body, java.lang.String direction)
body
- is the agent body.direction
- is "left" or "right"public void grab(AgentBody body)
body
- is the agent body.public boolean termination()
termination
in class Environment
public void updateEnv()
updateEnv
in class Environment
public void removeObj(Location loc, Obj ob)
loc
- is location in grid.ob
- is object to be removedpublic void addObj(Location loc, Obj ob)
loc
- is the location in grid.ob
- is object to be added.public void fillGrid(double prob, java.lang.Class c)
prob
- is the probability of object occurring.c
- is class to be added to grid.public void fillLoc(Location loc, java.lang.Class c)
public boolean contains(java.util.Vector v, java.lang.Class c)
v
- is the vector.c
- is the given class.public Obj getItem(java.util.Vector v, java.lang.Class c)
v
- is the vector.c
- is the class.public boolean neighbor(Location loc, java.lang.Class c)
loc
- is a grid location.c
- is a class.public void snapshot()
snapshot
in class Environment
public static final void copyGrid(GridEnvironment from, GridEnvironment to, int xsize, int ysize)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |