public class OdorWorld
extends java.lang.Object
Constructor and Description |
---|
OdorWorld()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addAgent(OdorWorldEntity entity)
Adds an agent and by default adds several sensors and effectors to it.
|
void |
addEntity(OdorWorldEntity entity)
Add an Odor World Entity.
|
void |
addListener(WorldListener listener)
Add a world listener.
|
boolean |
containsEntity(OdorWorldEntity entity)
Does the world contain this entity?
|
void |
deleteAllEntities()
Delete all entities.
|
void |
deleteEntity(OdorWorldEntity entity)
Delete entity.
|
void |
fireEffectorAdded(Effector effector)
Fire effector added event.
|
void |
fireEffectorRemoved(Effector effector)
Fire effector removed event.
|
void |
fireEntityAdded(OdorWorldEntity entity)
Fire entity added event.
|
void |
fireEntityChanged(OdorWorldEntity entity)
Fire entity changed event.
|
void |
fireEntityRemoved(OdorWorldEntity entity)
Fire entity removed event.
|
void |
firePropertyChangedEvent()
Fire a property changed event.
|
void |
fireSensorAdded(Sensor sensor)
Fire sensor added event.
|
void |
fireSensorRemoved(Sensor sensor)
Fire sensor removed event.
|
void |
fireUpdateEvent()
Fire an update event.
|
Effector |
getEffector(java.lang.String entityId,
java.lang.String effectorId)
Returns the effector with the given id, or null if none is found.
|
OdorWorldEntity |
getEntity(java.lang.String id)
Returns the entity with the given id, or, failing that, a given name.
|
int |
getHeight()
Returns height of world in pixels.
|
java.util.List<OdorWorldEntity> |
getObjectList()
Returns the list of entities.
|
Sensor |
getSensor(java.lang.String entityId,
java.lang.String sensorId)
Returns the sensor with the given id, or null if none is found.
|
double |
getTotalSmellVectorLength() |
int |
getWidth()
Returns width of world in pixels.
|
boolean |
getWrapAround() |
(package private) static com.thoughtworks.xstream.XStream |
getXStream()
Returns a properly initialized xstream object.
|
boolean |
isObjectsBlockMovement() |
void |
loadStimulusVectors(double[][] stimulusVecs)
Use the provided set of vectors (stored as a 2-d array of doubles, one
vector per row) to set the stimulus vectors on all odor world entities,
in the order in which they are stored in the internal list (which should
match the order in which they were added to the world).
|
void |
setHeight(int height) |
void |
setHeight(int newHeight,
boolean fireEvent)
Set height.
|
void |
setObjectsBlockMovement(boolean objectsBlockMovement) |
void |
setWidth(int width) |
void |
setWidth(int newWidth,
boolean fireEvent)
Set width.
|
void |
setWrapAround(boolean wrapAround) |
void |
update(int time)
Update world.
|
public void update(int time)
time
- an integer representation of time.public void addEntity(OdorWorldEntity entity)
entity
- the entity to addpublic boolean containsEntity(OdorWorldEntity entity)
entity
- the entity to check forpublic void addAgent(OdorWorldEntity entity)
entity
- the entity corresponding to the agentpublic OdorWorldEntity getEntity(java.lang.String id)
id
- name of entitypublic Sensor getSensor(java.lang.String entityId, java.lang.String sensorId)
entityId
- entity idsensorId
- sensor idpublic Effector getEffector(java.lang.String entityId, java.lang.String effectorId)
entityId
- entity ideffectorId
- sensor idpublic void deleteEntity(OdorWorldEntity entity)
entity
- the entity to deletepublic void deleteAllEntities()
static com.thoughtworks.xstream.XStream getXStream()
public void addListener(WorldListener listener)
listener
- listener to add.public java.util.List<OdorWorldEntity> getObjectList()
public void fireEntityAdded(OdorWorldEntity entity)
entity
- entity that was addedpublic void fireEntityRemoved(OdorWorldEntity entity)
entity
- entity that was removedpublic void fireEntityChanged(OdorWorldEntity entity)
entity
- entity that was changedpublic void fireSensorAdded(Sensor sensor)
sensor
- sensor that was addedpublic void fireSensorRemoved(Sensor sensor)
sensor
- sensor that was removedpublic void fireEffectorAdded(Effector effector)
effector
- effector that was addedpublic void fireEffectorRemoved(Effector effector)
effector
- effector that was removedpublic void fireUpdateEvent()
public void firePropertyChangedEvent()
public boolean getWrapAround()
public void setWrapAround(boolean wrapAround)
wrapAround
- the wrapAround to setpublic void setWidth(int newWidth, boolean fireEvent)
newWidth
- new widthfireEvent
- whether to fire a property changed eventpublic void setHeight(int newHeight, boolean fireEvent)
newHeight
- new heightfireEvent
- whether to fire a property changed eventpublic void setHeight(int height)
height
- the height to setpublic void setWidth(int width)
width
- the width to setpublic int getWidth()
public int getHeight()
public boolean isObjectsBlockMovement()
public void setObjectsBlockMovement(boolean objectsBlockMovement)
objectsBlockMovement
- the objectsBlockMovement to setpublic double getTotalSmellVectorLength()
public void loadStimulusVectors(double[][] stimulusVecs)
stimulusVecs
- the 2d matrix of stimulus vectors