|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jason.environment.grid.GridWorldModel
public class GridWorldModel
Simple model for a grid world (with agents and obstacles).
Every agent gets an identification (a integer from 0 to the number of ag - 1). The relation of this identification with agent's name should be done in the environment class and is application dependent.
Every type of object in the environment is represented by a bit mask: an agent is 000010; an obstacle is 000100; .... New types of objects should follow this pattern, for example, GOLD = 8 (001000), ENEMY=16 (010000), ... A place with two object is represented by the OR between the masks: an agent and a gold is 001010.
Limitations:
Field Summary | |
---|---|
static int |
AGENT
|
protected Location[] |
agPos
|
static int |
CLEAN
|
protected int[][] |
data
|
protected int |
height
|
static int |
OBSTACLE
|
protected java.util.Random |
random
|
protected GridWorldView |
view
|
protected int |
width
|
Constructor Summary | |
---|---|
protected |
GridWorldModel(int w,
int h,
int nbAgs)
|
Method Summary | |
---|---|
void |
add(int value,
int x,
int y)
|
void |
add(int value,
Location l)
|
void |
addWall(int x1,
int y1,
int x2,
int y2)
|
int |
countObjects(int obj)
|
int |
getAgAtPos(int x,
int y)
returns the agent at x,y or -1 if there is not one there |
int |
getAgAtPos(Location l)
returns the agent at location l or -1 if there is not one there |
Location |
getAgPos(int ag)
|
protected Location |
getFreePos()
returns a random free location using isFree to test the availability of some possible location (it means free of agents and obstacles) |
protected Location |
getFreePos(int obj)
returns a random free location using isFree(object) to test the availability of some possible location |
int |
getHeight()
|
int |
getNbOfAgs()
|
int |
getWidth()
|
boolean |
hasObject(int obj,
int x,
int y)
|
boolean |
hasObject(int obj,
Location l)
|
boolean |
inGrid(int x,
int y)
|
boolean |
inGrid(Location l)
|
boolean |
isFree(int x,
int y)
returns true if the location x,y has neither obstacle nor agent |
boolean |
isFree(int obj,
int x,
int y)
returns true if the location x,y has not the object obj |
boolean |
isFree(int obj,
Location l)
returns true if the location l has not the object obj |
boolean |
isFree(Location l)
returns true if the location l has no obstacle neither agent |
boolean |
isFreeOfObstacle(int x,
int y)
|
boolean |
isFreeOfObstacle(Location l)
|
void |
remove(int value,
int x,
int y)
|
void |
remove(int value,
Location l)
|
void |
set(int value,
int x,
int y)
|
void |
setAgPos(int ag,
int x,
int y)
|
void |
setAgPos(int ag,
Location l)
|
void |
setView(GridWorldView v)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int CLEAN
public static final int AGENT
public static final int OBSTACLE
protected int width
protected int height
protected int[][] data
protected Location[] agPos
protected GridWorldView view
protected java.util.Random random
Constructor Detail |
---|
protected GridWorldModel(int w, int h, int nbAgs)
Method Detail |
---|
public void setView(GridWorldView v)
public int getWidth()
public int getHeight()
public int getNbOfAgs()
public boolean inGrid(Location l)
public boolean inGrid(int x, int y)
public boolean hasObject(int obj, Location l)
public boolean hasObject(int obj, int x, int y)
public int countObjects(int obj)
public void set(int value, int x, int y)
public void add(int value, Location l)
public void add(int value, int x, int y)
public void addWall(int x1, int y1, int x2, int y2)
public void remove(int value, Location l)
public void remove(int value, int x, int y)
public void setAgPos(int ag, Location l)
public void setAgPos(int ag, int x, int y)
public Location getAgPos(int ag)
public int getAgAtPos(Location l)
public int getAgAtPos(int x, int y)
public boolean isFree(Location l)
public boolean isFree(int x, int y)
public boolean isFree(int obj, Location l)
public boolean isFree(int obj, int x, int y)
public boolean isFreeOfObstacle(Location l)
public boolean isFreeOfObstacle(int x, int y)
protected Location getFreePos()
protected Location getFreePos(int obj)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |