elge.world
Class World

java.lang.Object
  |
  +--elge.agent.Agent
        |
        +--elge.agent.AgentContainer
              |
              +--elge.world.World
All Implemented Interfaces:
EventListener, PropertyChangeListener, WorldRules
Direct Known Subclasses:
World2D

public abstract class World
extends AgentContainer
implements WorldRules, PropertyChangeListener

Class Basic world should define the rules, how it should work in the World. How to hold info about ancestor and provide them an enviroment. Every World consists of some elements, like monitors :). So, we should make them here.

Author:
Palino

Field Summary
static String[] agentCycleTypes
           
static String ASK_RND_POSITION
           
static String PROP_REPRESENTATION
           
static String[] removeAgentsTypes
           
static String RESULT_GENERATED_POSITION
           
 
Fields inherited from class elge.agent.AgentContainer
agents, innerAgency
 
Fields inherited from class elge.agent.Agent
actualSituation, agency, agencyClass, agentClassCounter, id, name, registered
 
Fields inherited from interface elge.world.WorldRules
LIFE_TICK, RESULT, SENSE_ALL_AGENTS, SENSE_VECTOR_VIEW, SENSE_VIEW, STD_ADDAGENT, STD_DELAGENT
 
Constructor Summary
World()
          Creates a new instance of BasicWorld
 
Method Summary
 void add(Agent a)
          adds an agent to the system and sets it the agency.
 void addPropertyChangeListener(PropertyChangeListener listener)
           
 Situation createSituationForAgent(Agent agent, Object params)
           
 ComboInteger getAgentCycle()
           
 Situation getAnswer_addAgent(Agent agent, Object params)
          This should be a method, wich can add new agents to the system.
 Situation getAnswer_delAgent(Agent agent, Object params)
          This should remove the agent from the system...
 Situation getAnswer_rndPosition(Agent agent, Object params)
          This calls the AgentRepresentation object to generate a new position..
 Situation getAnswer_sense(Agent agent, Object params)
          monitors - all monitors registred in the world
 Dimension getDimension()
           
 WorldDisplay getDisplay()
           
 ComboInteger getRemoveAgent()
           
 AgentRepresentation getRepresentation()
           
 int getTick()
           
 void init()
          This method performs initializing of the agent.
 boolean isPaintable()
           
 void life()
          The life cycle of the AgentContainer is different, because it should handle the angents it sonsist of, and not himeself (but yo may want to do this anyway).
 void paint(Graphics gfx)
           
 void propertyChange(PropertyChangeEvent evt)
          This method gets called when a bound property is changed.
 void remove(Agent a)
           
 void removePropertyChangeListener(PropertyChangeListener listener)
           
 void restart()
          Restarts the world, zeros tick counter, removes agents or restart them...
 void sense()
          First method for the agent life cycle.
 void setAgentCycle(ComboInteger ci)
           
 void setDimension(Dimension d)
           
 void setDisplay(WorldDisplay wd)
           
 void setRemoveAgent(ComboInteger ci)
           
 void setRepresentation(AgentRepresentation wr)
           
 void setTick(int tickCount)
           
 
Methods inherited from class elge.agent.AgentContainer
add, add, agentsLife, del, getAgentCount, getAgents, setAgents
 
Methods inherited from class elge.agent.Agent
ask, ask, ask, createDefaultAgency, createUniqueID, getAgency, getFullName, getID, getName, chooseAction, life, memorize, setAgency, setAgency, setAgency, setID, setName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PROP_REPRESENTATION

public static final String PROP_REPRESENTATION
See Also:
Constant Field Values

RESULT_GENERATED_POSITION

public static final String RESULT_GENERATED_POSITION
See Also:
Constant Field Values

ASK_RND_POSITION

public static final String ASK_RND_POSITION
See Also:
Constant Field Values

agentCycleTypes

public static final String[] agentCycleTypes

removeAgentsTypes

public static final String[] removeAgentsTypes
Constructor Detail

World

public World()
Creates a new instance of BasicWorld

Method Detail

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)

add

public void add(Agent a)
Description copied from class: AgentContainer
adds an agent to the system and sets it the agency.

Overrides:
add in class AgentContainer
Parameters:
a - agent to add

remove

public void remove(Agent a)

getAnswer_sense

public Situation getAnswer_sense(Agent agent,
                                 Object params)
monitors - all monitors registred in the world


sense

public void sense()
Description copied from class: Agent
First method for the agent life cycle.

Overrides:
sense in class Agent

createSituationForAgent

public Situation createSituationForAgent(Agent agent,
                                         Object params)

getAnswer_addAgent

public final Situation getAnswer_addAgent(Agent agent,
                                          Object params)
This should be a method, wich can add new agents to the system. Question is, can this use all agents? Or only some type of them? What if another agent is willing to have a method of this name?


getAnswer_delAgent

public final Situation getAnswer_delAgent(Agent agent,
                                          Object params)
This should remove the agent from the system... TODO


getAnswer_rndPosition

public final Situation getAnswer_rndPosition(Agent agent,
                                             Object params)
This calls the AgentRepresentation object to generate a new position..


paint

public void paint(Graphics gfx)

isPaintable

public boolean isPaintable()

init

public void init()
Description copied from class: Agent
This method performs initializing of the agent. This method is called every time agent is added to the world or when the init of the world is called.

Overrides:
init in class Agent

restart

public void restart()
Restarts the world, zeros tick counter, removes agents or restart them...

Overrides:
restart in class Agent

life

public void life()
Description copied from class: AgentContainer
The life cycle of the AgentContainer is different, because it should handle the angents it sonsist of, and not himeself (but yo may want to do this anyway).

Overrides:
life in class AgentContainer

setRepresentation

public void setRepresentation(AgentRepresentation wr)

getRepresentation

public AgentRepresentation getRepresentation()

setDisplay

public void setDisplay(WorldDisplay wd)

getDisplay

public WorldDisplay getDisplay()

setDimension

public void setDimension(Dimension d)

getDimension

public Dimension getDimension()

getTick

public int getTick()

setTick

public void setTick(int tickCount)

setAgentCycle

public void setAgentCycle(ComboInteger ci)

getAgentCycle

public ComboInteger getAgentCycle()

setRemoveAgent

public void setRemoveAgent(ComboInteger ci)

getRemoveAgent

public ComboInteger getRemoveAgent()

propertyChange

public void propertyChange(PropertyChangeEvent evt)
This method gets called when a bound property is changed.

Specified by:
propertyChange in interface PropertyChangeListener
Parameters:
evt - A PropertyChangeEvent object describing the event source and the property that has changed.