|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectrescuecore.Memory
This class holds an agents view of the world
Field Summary |
Constructor Summary | |
protected |
Memory()
Construct a new empty memory |
Method Summary | |
void |
add(RescueObject o,
int timestamp)
Add a new object |
void |
addMemoryListener(MemoryListener l)
Add a MemoryListener that will be informed of adds and updates |
boolean |
canPass(Road road,
int positionExtra,
Node target)
Test whether an agent can pass a particular road in a certain direction |
RescueObject[] |
findBuildingNeighbours(Building b)
Find the neighbours of a Building. |
RescueObject[] |
findNeighbours(RescueObject o)
Find the neighbours of a RescueObject. |
RescueObject[] |
findNodeNeighbours(Node node)
Find the neighbours of a Node. |
RescueObject[] |
findRoadNeighbours(Road road)
Find the neighbours of a Road. |
abstract RescueObject[] |
getAllObjects()
Get all objects in memory |
abstract java.util.Collection |
getAllObjectsAsCollection()
Get all objects in memory as a Collection |
int |
getAngle(RescueObject from,
RescueObject to)
Get the angle in arc-seconds from one object to another |
Node |
getClosestNode(RescueObject o)
Find the closest Node to a RescueObject. |
Node |
getClosestNode(Road road,
int positionExtra)
Get the node id (either head or tail of the given road) that is closest to the position given |
double |
getDistance(RescueObject o1,
RescueObject o2)
Get the Euclidean distance between two objects |
int |
getHeight()
Get the height of the world |
abstract RescueObject[] |
getObjectsOfInternalType(int type)
Get all objects of a particular internal type |
abstract RescueObject[] |
getObjectsOfType(int type)
Get all objects of a particular type |
int |
getWidth()
Get the width of the world |
int[] |
getXY(RescueObject o)
Get the X and Y coordinates of an object |
abstract RescueObject |
lookup(int id)
Look up a RescueObject by id |
void |
remove(RescueObject o)
Remove an object from the memory |
void |
removeMemoryListener(MemoryListener l)
Remove a MemoryListener |
void |
update(java.io.DataInput in,
int timestep)
Update our memory from an Objects structure |
void |
updateFromKA_SENSE(byte[] data,
MutableInteger index,
int timestep)
Deprecated. Replaced by @{link update(DataInput, int)} |
void |
updateFromKS_UPDATE(byte[] data,
MutableInteger index,
int timestep)
Deprecated. Replaced by @{link update(DataInput, int)} |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
protected Memory()
Method Detail |
public int getWidth()
public int getHeight()
public void addMemoryListener(MemoryListener l)
l
- The MemoryListener to addpublic void removeMemoryListener(MemoryListener l)
l
- The MemoryListener to removepublic abstract RescueObject lookup(int id)
id
- The id of the object we want
public abstract RescueObject[] getAllObjects()
public abstract java.util.Collection getAllObjectsAsCollection()
public abstract RescueObject[] getObjectsOfType(int type)
type
- The type we want
RescueConstants.TYPE_CIVILIAN
,
RescueConstants.TYPE_FIRE_BRIGADE
,
RescueConstants.TYPE_AMBULANCE_TEAM
,
RescueConstants.TYPE_POLICE_FORCE
,
RescueConstants.TYPE_ROAD
,
RescueConstants.TYPE_NODE
,
RescueConstants.TYPE_RIVER
,
RescueConstants.TYPE_RIVER_NODE
,
RescueConstants.TYPE_BUILDING
,
RescueConstants.TYPE_REFUGE
,
RescueConstants.TYPE_FIRE_STATION
,
RescueConstants.TYPE_AMBULANCE_CENTER
,
RescueConstants.TYPE_POLICE_OFFICE
,
RescueConstants.TYPE_WORLD
,
RescueConstants.TYPE_CAR
public abstract RescueObject[] getObjectsOfInternalType(int type)
type
- The type we want
RescueConstants.INTERNAL_TYPE_CIVILIAN
,
RescueConstants.INTERNAL_TYPE_FIRE_BRIGADE
,
RescueConstants.INTERNAL_TYPE_AMBULANCE_TEAM
,
RescueConstants.INTERNAL_TYPE_POLICE_FORCE
,
RescueConstants.INTERNAL_TYPE_CAR
,
RescueConstants.INTERNAL_TYPE_BUILDING
,
RescueConstants.INTERNAL_TYPE_REFUGE
,
RescueConstants.INTERNAL_TYPE_FIRE_STATION
,
RescueConstants.INTERNAL_TYPE_POLICE_OFFICE
,
RescueConstants.INTERNAL_TYPE_AMBULANCE_CENTER
,
RescueConstants.INTERNAL_TYPE_ROAD
,
RescueConstants.INTERNAL_TYPE_NODE
,
RescueConstants.INTERNAL_TYPE_RIVER
,
RescueConstants.INTERNAL_TYPE_RIVER_NODE
,
RescueConstants.INTERNAL_TYPE_WORLD
,
RescueConstants.INTERNAL_TYPE_ANY_BUILDING
,
RescueConstants.INTERNAL_TYPE_ANY_HUMANOID
public void add(RescueObject o, int timestamp)
o
- The new objecttimestamp
- The time that this object is addedpublic void remove(RescueObject o)
o
- The object to be removedpublic final void update(java.io.DataInput in, int timestep) throws UnknownPropertyException, UnknownTypeException, java.io.IOException
in
- The DataInput to read data fromtimestep
- The current timestep
UnknownTypeException
- if an unknown object type appears
UnknownPropertyException
- if an unknown property shows up
java.io.IOException
- if there is an IO problempublic final void updateFromKA_SENSE(byte[] data, MutableInteger index, int timestep) throws UnknownPropertyException, UnknownTypeException
data
- The body of the KA_SENSEindex
- The index to start reading the message from. This index should be updated to point to the byte after the end of the message after decodingtimestep
- The current timestep
UnknownTypeException
- if an unknown object type appears
UnknownPropertyException
- if an unknown property shows uppublic final void updateFromKS_UPDATE(byte[] data, MutableInteger index, int timestep) throws UnknownPropertyException, UnknownTypeException
data
- The body of the KS_UPDATEindex
- The index to start reading the message from. This index should be updated to point to the byte after the end of the message after decodingtimestep
- The current timestep
UnknownTypeException
- if an unknown object type appears
UnknownPropertyException
- if an unknown property shows uppublic double getDistance(RescueObject o1, RescueObject o2)
o1
- The first objecto2
- The second object
public int getAngle(RescueObject from, RescueObject to)
from
- The first objectto
- The second object
public int[] getXY(RescueObject o)
o
- The object of interest
public Node getClosestNode(RescueObject o)
o
- The object we want the closest node to
public Node getClosestNode(Road road, int positionExtra)
road
- The road that we want the head or tail ofpositionExtra
- The agent's position along the road
public RescueObject[] findNeighbours(RescueObject o)
o
- The RescueObject we want the neighbours for
public RescueObject[] findNodeNeighbours(Node node)
node
- The Node we want the neighbours for
public RescueObject[] findRoadNeighbours(Road road)
road
- The Road we want the neighbours for
public RescueObject[] findBuildingNeighbours(Building b)
b
- The Building we want the neighbours for
public boolean canPass(Road road, int positionExtra, Node target)
road
- The road to testpositionExtra
- The distance along the road where the agent is nowtarget
- The target node - either the head or the tail of this road
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |