de.cesr.lara.houseplant
Class Environment

java.lang.Object
  extended by de.cesr.lara.components.environment.impl.LEnvironment
      extended by de.cesr.lara.houseplant.Environment
All Implemented Interfaces:
LaraEnvironment, LaraSuperEnvironment, LaraAbstractEventSubscriber, LaraEventSubscriber

public class Environment
extends LEnvironment
implements LaraEventSubscriber

the agents environment. wraps his social and geo-physical environment into one place. environmental properties are stored key-value based.


Field Summary
static String ENVIRONMENT_CATEGORY_HABITATION
           
static String ENVIRONMENT_CATEGORY_SOCIAL
           
static String ENVIRONMENT_CATEGORY_WEATHER
           
 
Fields inherited from class de.cesr.lara.components.environment.impl.LEnvironment
abstractProperties, allObserver, propertyObserver, subEnvironments
 
Fields inherited from interface de.cesr.lara.components.environment.LaraSuperEnvironment
ALL_CATEGORIES
 
Constructor Summary
Environment(SimulationConfig simulationConfig)
           
 
Method Summary
 void behaveByHabit(String agentId, boolean hasBehavedByHabit)
          save information if agent behaved by habit
 void doNotIrrigateHouseplant(String agentId, String habitationId)
          save information that agent did not irrigate houseplant
 Set<String> getAgentIds()
           
 Double getAmountOfWaterForHouseplant(String habitationId)
           
 Set<String> getHabitationIds()
           
 double getPercentageOfCollaboratorsWhoIrrigatedLastTimestep(String agentId)
           
 int getSizeOfHouseplant(String habitationId)
           
 int getSunshineDuration()
           
 boolean hasAgentBehavedByHabit(String agentId)
           
 boolean hasAgentIrrigatedLastTimestep(String agentId)
           
 void irrigateHouseplant(String agentId, String habitationId)
          save information that agent irrigated houseplant
<T extends LaraEvent>
void
onEvent(T event)
          Will be called with an event as a parameter when an event the subscriber subscribed to occurs.
 void placeAgentInEnvironment(String agentId, String habitationId, List<String> collaboratorIds)
          Places the agent into the environment.
 
Methods inherited from class de.cesr.lara.components.environment.impl.LEnvironment
addEnvListener, addEnvListener, addProperty, containsProperty, containsProperty, getAllListeners, getEnvProperties, getPropertyByName, getSubEnvironments, getSubEnvironments, getTypedPropertyByName, inform, registerEnvironment, removeEnvironment, removeEnvironment, removeEnvListener, removeEnvListener, removeProperty, removeProperty, removePropertySubenv, toString, updateProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ENVIRONMENT_CATEGORY_SOCIAL

public static final String ENVIRONMENT_CATEGORY_SOCIAL
See Also:
Constant Field Values

ENVIRONMENT_CATEGORY_HABITATION

public static final String ENVIRONMENT_CATEGORY_HABITATION
See Also:
Constant Field Values

ENVIRONMENT_CATEGORY_WEATHER

public static final String ENVIRONMENT_CATEGORY_WEATHER
See Also:
Constant Field Values
Constructor Detail

Environment

public Environment(SimulationConfig simulationConfig)
Method Detail

onEvent

public <T extends LaraEvent> void onEvent(T event)
Description copied from interface: LaraEventSubscriber
Will be called with an event as a parameter when an event the subscriber subscribed to occurs. Implement this to react on events. Typically you would start doing something like if (event instanceof VeryInterestingEvent) { //do something smart }

Specified by:
onEvent in interface LaraEventSubscriber

getHabitationIds

public Set<String> getHabitationIds()
Returns:
all ids of habitations currently in the simulation

placeAgentInEnvironment

public void placeAgentInEnvironment(String agentId,
                                    String habitationId,
                                    List<String> collaboratorIds)
Places the agent into the environment. The agent id, collaborators and habitation will be stored. If the habitation he belongs to does not exist, a new habitation will be created.

Parameters:
agentId -
habitationId -
collaboratorIds -

getAgentIds

public Set<String> getAgentIds()
Returns:
all ids of the available agents

behaveByHabit

public void behaveByHabit(String agentId,
                          boolean hasBehavedByHabit)
save information if agent behaved by habit

Parameters:
agentId -

irrigateHouseplant

public void irrigateHouseplant(String agentId,
                               String habitationId)
save information that agent irrigated houseplant

Parameters:
agentId -
habitationId -

doNotIrrigateHouseplant

public void doNotIrrigateHouseplant(String agentId,
                                    String habitationId)
save information that agent did not irrigate houseplant

Parameters:
agentId -
habitationId -

getSunshineDuration

public int getSunshineDuration()
Returns:
sunshine duration for current timestep

getPercentageOfCollaboratorsWhoIrrigatedLastTimestep

public double getPercentageOfCollaboratorsWhoIrrigatedLastTimestep(String agentId)
Parameters:
agentId -
Returns:
the percentage of collaborators of the given agent who irrigated the houseplant in the last timestep

hasAgentBehavedByHabit

public boolean hasAgentBehavedByHabit(String agentId)
Parameters:
agentId -
Returns:
true if the given agent has behaved by habit in the last timestep otherwise false

hasAgentIrrigatedLastTimestep

public boolean hasAgentIrrigatedLastTimestep(String agentId)
Parameters:
agentId -
Returns:
true if the given agent has irrigated the houseplant in the last timestep

getAmountOfWaterForHouseplant

public Double getAmountOfWaterForHouseplant(String habitationId)
Parameters:
habitationId -
Returns:
the amount of water for the houseplant in the given habitation

getSizeOfHouseplant

public int getSizeOfHouseplant(String habitationId)
Parameters:
habitationId -
Returns:
the size of the houseplant in the given habitation