physis.core
Class RemoteDigitalOrganism

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

public class RemoteDigitalOrganism
extends java.lang.Object
implements DigitalOrganism

This class represents a remote digital organism. It accesses a remote DigitalOrganism object through a socket via the Digital Organism Transfer Protocol (DOTP). If the socket breaks down it uses a local reference. Each methods defiened in the DigitalOrganism interface simply delegates the operations to a remote proxy. Actually it communicates with a DigitalOrganismProxy.


Field Summary
protected  java.io.BufferedReader in
           
protected  int index
          The index of the remote digital organism.
protected  DigitalOrganism localRef
          If the connection breaks down this local reference shoud be used.
protected  java.io.PrintWriter out
           
protected  java.net.Socket socket
          The socket used for the DOTP commmunication with a remote Digital Org proxy.
 
Constructor Summary
RemoteDigitalOrganism(int index_, java.net.Socket socket_, java.io.BufferedReader in_, java.io.PrintWriter out_, DigitalOrganism local_ref)
           
 
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.
 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, toString, wait, wait, wait
 

Field Detail

socket

protected java.net.Socket socket
The socket used for the DOTP commmunication with a remote Digital Org proxy.

in

protected java.io.BufferedReader in

out

protected java.io.PrintWriter out

index

protected int index
The index of the remote digital organism.

localRef

protected DigitalOrganism localRef
If the connection breaks down this local reference shoud be used.
Constructor Detail

RemoteDigitalOrganism

public RemoteDigitalOrganism(int index_,
                             java.net.Socket socket_,
                             java.io.BufferedReader in_,
                             java.io.PrintWriter out_,
                             DigitalOrganism local_ref)
Method Detail

vivify

public void vivify(DigitalOrganism neighbour_,
                   GeneticCodeTape codetape,
                   int inherited_length)
Description copied from interface: DigitalOrganism
Makes the organism to be alive. (Fills the vital parts.) This operation should entirely reset the organism's state.
Specified by:
vivify in interface DigitalOrganism
Following copied from interface: physis.core.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. (This is a trick: the newly born organism should have some reasonable value in order to survive. In the next update after it's born the effective length is recalculated.

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

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

getFitness

public double getFitness()
Description copied from interface: DigitalOrganism
Returns the fitness value of the organism.
Specified by:
getFitness 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