physis.core
Class DigitalOrganismImpl

java.lang.Object
  |
  +--physis.core.DigitalOrganismImpl
All Implemented Interfaces:
DigitalOrganism

public class DigitalOrganismImpl
extends java.lang.Object
implements DigitalOrganism

Plain implementation of the DigitalOrganism interface. This is used in most cases.


Field Summary
protected  int age
          The age of the organism in updates.
protected  double fitness
           
protected  boolean isAlive
          Indicates that the organism is ready to run
protected  boolean isfertile
          Indicates that the organism could bear at least one child
static int IT_DOESNT_COUNT_ANY_MORE
          When a task is performed too many times than it doesn't mean any bonus.
protected  Merit merit
          The organism's merit
protected  Metabolism metabolism
          It is actually the virtualmachine's I/O buffer.
protected  DigitalOrganism neighbour
          One of the organism's neighbours is special because all the close interactions happen between two organism.
protected  PerformedTasksRegister performed_tasks
          This hashtable keeps track the performed tasks.
protected  java.lang.Object position_info
          This is information about the position of the organism in the lifespace.
protected  PhysisVirtualMachine vm
          The "heart" of the organism
 
Constructor Summary
DigitalOrganismImpl()
          It simply creates the organism - it doesn't mean it's alive.
DigitalOrganismImpl(java.lang.String vm_classname)
           
 
Method Summary
 int getAge()
          Gives the age of the organism.
 int getEffectiveLength()
          Returns the effective length.
 double getFitness()
          Returns the fitness value of the organism.
 Genome getGenome()
          Gives the genetic information of the organism.
 int getGenomeSize()
          Gives the size of the organism's genome.
 int getMerit()
          Retruns the merit.
 Metabolism getMetabolism()
          Gives the Metabolism of the organism.
 DigitalOrganism getNeighbour()
          Returns the organism's neighbour.
 PerformedTasksRegister getPerformedTasks()
          Gives the container of the performed tasks.
 java.lang.Object getPositinInfo()
          Gives the position information.
 PhysisVirtualMachine getVM()
          Returns the organism's internal virtual machine.
 void increaseAge()
          Increments the age by 1.
 boolean isAlive()
          Tells whether the organism is alive or not.
 boolean isFertile()
          Tells whether the organism is fertile (capable to yield a child).
 void kill()
          Kills the organism.
 void recalculateBonus(double bonus_multiplier)
          Recalculates the organism's bonus by multiplying it with the bonus multiplier.
 void recalculateEffectiveLength()
          Recalculates the effective length.
 void recalculateFitness()
          Recalculates the fitness.
 void setFertile(boolean fertility)
          Sets the fertility flag.
 void setNeighbour(DigitalOrganism digorg)
          Sets the organism neighbour.
 void setPositionInfo(java.lang.Object o)
          Sets the position information.
 java.lang.String toString()
           
 void update()
          Updates the organism's state by executing one cpu-cycle.
 void update(int cpu_cycles)
          Updates the organism's state by executing given amount of cpu_cycles.
 void vivify(DigitalOrganism neighbour_, GeneticCodeTape codetape, int inherited_length)
          Makes the organism to be alive.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

age

protected int age
The age of the organism in updates.

isfertile

protected boolean isfertile
Indicates that the organism could bear at least one child

isAlive

protected boolean isAlive
Indicates that the organism is ready to run

merit

protected Merit merit
The organism's merit

vm

protected PhysisVirtualMachine vm
The "heart" of the organism

metabolism

protected Metabolism metabolism
It is actually the virtualmachine's I/O buffer.

neighbour

protected DigitalOrganism neighbour
One of the organism's neighbours is special because all the close interactions happen between two organism.

fitness

protected double fitness

position_info

protected java.lang.Object position_info
This is information about the position of the organism in the lifespace. This attribute's type is defined in the corresponding LifeSpace class.

performed_tasks

protected PerformedTasksRegister performed_tasks
This hashtable keeps track the performed tasks. The keys are tasknames, and the values are numbers indicating how many times the was performed the task.

IT_DOESNT_COUNT_ANY_MORE

public static int IT_DOESNT_COUNT_ANY_MORE
When a task is performed too many times than it doesn't mean any bonus.
Constructor Detail

DigitalOrganismImpl

public DigitalOrganismImpl()
It simply creates the organism - it doesn't mean it's alive.

DigitalOrganismImpl

public DigitalOrganismImpl(java.lang.String vm_classname)
Method Detail

vivify

public void vivify(DigitalOrganism neighbour_,
                   GeneticCodeTape codetape,
                   int inherited_length)
Makes the organism to be alive. (Fills the vital parts.)
Specified by:
vivify in interface DigitalOrganism
Parameters:
neighbour_ - The organism to which this is facing.
codetape - The new seed.
inherited_length - The newly born organism inherits the parent's effective length.

kill

public void kill()
Kills the organism.
Specified by:
kill in interface DigitalOrganism

increaseAge

public void increaseAge()
Description copied from interface: DigitalOrganism
Increments the age by 1. Ususally it should happen after an update.
Specified by:
increaseAge in interface DigitalOrganism

getAge

public int getAge()
Description copied from interface: DigitalOrganism
Gives the age of the organism.
Specified by:
getAge in interface DigitalOrganism

isAlive

public boolean isAlive()
Description copied from interface: DigitalOrganism
Tells whether the organism is alive or not.
Specified by:
isAlive in interface DigitalOrganism

isFertile

public boolean isFertile()
Description copied from interface: DigitalOrganism
Tells whether the organism is fertile (capable to yield a child).
Specified by:
isFertile in interface DigitalOrganism

setFertile

public void setFertile(boolean fertility)
Description copied from interface: DigitalOrganism
Sets the fertility flag.
Specified by:
setFertile in interface DigitalOrganism

getVM

public PhysisVirtualMachine getVM()
Description copied from interface: DigitalOrganism
Returns the organism's internal virtual machine.
Specified by:
getVM in interface DigitalOrganism

getGenome

public Genome getGenome()
Description copied from interface: DigitalOrganism
Gives the genetic information of the organism.
Specified by:
getGenome in interface DigitalOrganism

getGenomeSize

public int getGenomeSize()
Description copied from interface: DigitalOrganism
Gives the size of the organism's genome.
Specified by:
getGenomeSize in interface DigitalOrganism

getMetabolism

public Metabolism getMetabolism()
Description copied from interface: DigitalOrganism
Gives the Metabolism of the organism.
Specified by:
getMetabolism in interface DigitalOrganism

getPerformedTasks

public PerformedTasksRegister getPerformedTasks()
Description copied from interface: DigitalOrganism
Gives the container of the performed tasks.
Specified by:
getPerformedTasks in interface DigitalOrganism

update

public void update()
Description copied from interface: DigitalOrganism
Updates the organism's state by executing one cpu-cycle.
Specified by:
update in interface DigitalOrganism

update

public void update(int cpu_cycles)
Description copied from interface: DigitalOrganism
Updates the organism's state by executing given amount of cpu_cycles.
Specified by:
update in interface DigitalOrganism

getFitness

public double getFitness()
Description copied from interface: DigitalOrganism
Returns the fitness value of the organism.
Specified by:
getFitness in interface DigitalOrganism

recalculateFitness

public void recalculateFitness()
Description copied from interface: DigitalOrganism
Recalculates the fitness. Should be callled after successfull divede (by the Environment)
Specified by:
recalculateFitness in interface DigitalOrganism

recalculateBonus

public void recalculateBonus(double bonus_multiplier)
Description copied from interface: DigitalOrganism
Recalculates the organism's bonus by multiplying it with the bonus multiplier.
Specified by:
recalculateBonus in interface DigitalOrganism

getEffectiveLength

public int getEffectiveLength()
Description copied from interface: DigitalOrganism
Returns the effective length.
Specified by:
getEffectiveLength in interface DigitalOrganism

recalculateEffectiveLength

public void recalculateEffectiveLength()
Description copied from interface: DigitalOrganism
Recalculates the effective length.
Specified by:
recalculateEffectiveLength in interface DigitalOrganism

getMerit

public int getMerit()
Description copied from interface: DigitalOrganism
Retruns the merit.
Specified by:
getMerit in interface DigitalOrganism

setNeighbour

public void setNeighbour(DigitalOrganism digorg)
Description copied from interface: DigitalOrganism
Sets the organism neighbour.
Specified by:
setNeighbour in interface DigitalOrganism

getNeighbour

public DigitalOrganism getNeighbour()
Description copied from interface: DigitalOrganism
Returns the organism's neighbour.
Specified by:
getNeighbour in interface DigitalOrganism

setPositionInfo

public void setPositionInfo(java.lang.Object o)
Description copied from interface: DigitalOrganism
Sets the position information. The actual type of the info are is determined by the
Specified by:
setPositionInfo in interface DigitalOrganism

getPositinInfo

public java.lang.Object getPositinInfo()
Description copied from interface: DigitalOrganism
Gives the position information.
Specified by:
getPositinInfo in interface DigitalOrganism

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object