elge.world
Class AbstractGenerator

java.lang.Object
  |
  +--elge.agent.Agent
        |
        +--elge.agent.AgentContainer
              |
              +--elge.world.WorldAgent
                    |
                    +--elge.world.AbstractGenerator
All Implemented Interfaces:
MoveableAgent
Direct Known Subclasses:
AgentGenerator, AgentRemover

public abstract class AbstractGenerator
extends WorldAgent

The class is used a basic class for generator (or system agents). It defines some common things that the generator should have.

Author:
Pavol Žibrita

Field Summary
static int EXACT_GEN
          generate on exact tick value
static int FIRST_GEN
          generate on first tick
static String[] genCycleTypes
          The names of the generation types
static int NO_GEN
          do not generate
static int PERIOD_GEN
          generate on a period
static int TICK_GEN
          generate on every tick
 
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.MoveableAgent
PROP_POSITION
 
Constructor Summary
AbstractGenerator(String name)
          Creates a new instance of AbstractGenerator
 
Method Summary
protected abstract  void agentAction()
          define this method to generate, remove or whatevery you need to do.
 ComboInteger getGenCycleType()
          Sets the cycle type of the generation.
 int getGenPeriod()
          Returns the period in wich we should generate
 double getGenProb()
          returns the generation probability
 int getInOneStep()
          get the gen in one step value.
protected  void chooseAction()
          we generate in chooseAction method.
 boolean isGenerator()
          return true
 void setGenCycleType(ComboInteger i)
          Sets the generation type
 void setGenPeriod(int period)
          Sets the generation period if the cycle is of type 3, generating in period.
 void setGenProb(double prob)
          Sets the probability of generating an agent..
 void setInOneStep(int num)
          How many agents to generate in one step..
 
Methods inherited from class elge.world.WorldAgent
addVetoableChangeListener, getFullName, getGenerated, getGroup, getHidden, getPosition, paint, removeVetoableChangeListener, setGenerated, setGroup, setHidden, setPosition
 
Methods inherited from class elge.agent.AgentContainer
add, add, add, agentsLife, del, getAgentCount, getAgents, life, setAgents
 
Methods inherited from class elge.agent.Agent
ask, ask, ask, createDefaultAgency, createUniqueID, getAgency, getID, getName, init, life, memorize, restart, sense, 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

NO_GEN

public static final int NO_GEN
do not generate

See Also:
Constant Field Values

FIRST_GEN

public static final int FIRST_GEN
generate on first tick

See Also:
Constant Field Values

TICK_GEN

public static final int TICK_GEN
generate on every tick

See Also:
Constant Field Values

PERIOD_GEN

public static final int PERIOD_GEN
generate on a period

See Also:
Constant Field Values

EXACT_GEN

public static final int EXACT_GEN
generate on exact tick value

See Also:
Constant Field Values

genCycleTypes

public static final String[] genCycleTypes
The names of the generation types

Constructor Detail

AbstractGenerator

public AbstractGenerator(String name)
Creates a new instance of AbstractGenerator

Parameters:
name - The generator name.
Method Detail

isGenerator

public boolean isGenerator()
return true

Overrides:
isGenerator in class WorldAgent
Returns:
true

setInOneStep

public void setInOneStep(int num)
How many agents to generate in one step..

Parameters:
num - number of objects

getInOneStep

public int getInOneStep()
get the gen in one step value.

Returns:
number of objects to generate

getGenCycleType

public ComboInteger getGenCycleType()
Sets the cycle type of the generation. First time, every tic, or according to cycle count. 0 - do not generate agents; 1 - generate on first tick; 2 - generate on every tick; 3 - generate on every xy tick;

Returns:
the generation cycle type

setGenCycleType

public void setGenCycleType(ComboInteger i)
Sets the generation type

Parameters:
i - the combo integer of the gen cycle type..
See Also:
getGenCycleType()

setGenProb

public void setGenProb(double prob)
Sets the probability of generating an agent..

Parameters:
prob - the probability

getGenProb

public double getGenProb()
returns the generation probability

Returns:
the probability

setGenPeriod

public void setGenPeriod(int period)
Sets the generation period if the cycle is of type 3, generating in period.

Parameters:
period - the period

getGenPeriod

public int getGenPeriod()
Returns the period in wich we should generate

Returns:
the period

chooseAction

protected void chooseAction()
we generate in chooseAction method. AbstractGenerator calls the agentAction() if the generator should generate something...

Overrides:
chooseAction in class Agent

agentAction

protected abstract void agentAction()
define this method to generate, remove or whatevery you need to do.