physis.core
Class EnvironmentImpl

java.lang.Object
  |
  +--physis.core.EnvironmentImpl
All Implemented Interfaces:
Environment, java.util.EventListener, InteractionEventListener, ProliferationEventListener

public class EnvironmentImpl
extends java.lang.Object
implements Environment

The default implementation for the Environment


Field Summary
private  double copy_mutation_rate
           
private static java.lang.String COPY_MUTATION_RATE
           
private  double delete_rate
           
private static java.lang.String DELETE_RATE
           
private  double divide_mutation_rate
           
private static java.lang.String DIVIDE_MUTATION_RATE
           
private  int input_data_higher_bound
           
private static java.lang.String INPUT_DATA_HIGHER_BOUND
           
private  double insert_rate
           
private static java.lang.String INSERT_RATE
           
private  LifeSpace lifespace
           
private  Nurse nurse
           
private static java.lang.String RANDOM_SEED
           
private  java.util.Random rnd
           
private static java.lang.String TASK_FILE
           
private  TaskLibrary tasklibrary
           
 
Constructor Summary
EnvironmentImpl()
          The constructor is private because it's a singleton.
 
Method Summary
 boolean copyShouldBeMutated()
          Answers the question: Should the current copied instruction be mutated?
 boolean divideShouldBeMutated()
          Answers the question: Should the current divided codetape be mutated?
 int getInputData()
          This provides the input from the environment (~food).
 LifeSpace getLifeSpace()
           
 DigitalOrganism getNeighbourRandomly(DigitalOrganism digorg)
          Returns one organism of the neighbours of the organism specified by the parameter.
 java.util.Random getRandom()
          The only one random-generator in one Physis-instance should be in the environment.
 TaskLibrary getTaskLibrary()
          Returns the tasklibrary.
 void interactionOccured(InteractionEvent ie)
          Performed when an organism interacts with its environment.
 void proliferationPerformed(ProliferationEvent pe)
          When a digital organism divides the new organism must be placed somewhere in the lifespace and the old organism's effective length should be recalculated.
 void rotateForward(DigitalOrganism digorg)
          Rotates the organism's facing forward.
 void setLifeSpace(LifeSpace lifespace_)
           
 boolean shouldBeDeleted()
          Answers the question: Should the current divided codetape be deleted one instruction?
 boolean shouldBeInserted()
          Answers the question: Should the current divided codetape be inserted extra instructions?
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

RANDOM_SEED

private static java.lang.String RANDOM_SEED

TASK_FILE

private static java.lang.String TASK_FILE

COPY_MUTATION_RATE

private static java.lang.String COPY_MUTATION_RATE

DIVIDE_MUTATION_RATE

private static java.lang.String DIVIDE_MUTATION_RATE

INSERT_RATE

private static java.lang.String INSERT_RATE

DELETE_RATE

private static java.lang.String DELETE_RATE

INPUT_DATA_HIGHER_BOUND

private static java.lang.String INPUT_DATA_HIGHER_BOUND

rnd

private java.util.Random rnd

nurse

private Nurse nurse

tasklibrary

private TaskLibrary tasklibrary

lifespace

private LifeSpace lifespace

copy_mutation_rate

private double copy_mutation_rate

divide_mutation_rate

private double divide_mutation_rate

insert_rate

private double insert_rate

delete_rate

private double delete_rate

input_data_higher_bound

private int input_data_higher_bound
Constructor Detail

EnvironmentImpl

public EnvironmentImpl()
The constructor is private because it's a singleton. Can be instantiated by calling getInstance().
Method Detail

getTaskLibrary

public TaskLibrary getTaskLibrary()
Returns the tasklibrary.
Specified by:
getTaskLibrary in interface Environment

setLifeSpace

public void setLifeSpace(LifeSpace lifespace_)
Specified by:
setLifeSpace in interface Environment

getLifeSpace

public LifeSpace getLifeSpace()
Specified by:
getLifeSpace in interface Environment

interactionOccured

public void interactionOccured(InteractionEvent ie)
Description copied from interface: InteractionEventListener
Performed when an organism interacts with its environment.
Specified by:
interactionOccured in interface InteractionEventListener

proliferationPerformed

public void proliferationPerformed(ProliferationEvent pe)
Description copied from interface: ProliferationEventListener
When a digital organism divides the new organism must be placed somewhere in the lifespace and the old organism's effective length should be recalculated. The parent organism's VM should be reset. The parent orgainsm should be set fertile. These should be handled in this method by the implementor classes.
Specified by:
proliferationPerformed in interface ProliferationEventListener

getInputData

public int getInputData()
This provides the input from the environment (~food).
Specified by:
getInputData in interface Environment

rotateForward

public void rotateForward(DigitalOrganism digorg)
Rotates the organism's facing forward.
Specified by:
rotateForward in interface Environment

copyShouldBeMutated

public boolean copyShouldBeMutated()
Answers the question: Should the current copied instruction be mutated?
Specified by:
copyShouldBeMutated in interface Environment

divideShouldBeMutated

public boolean divideShouldBeMutated()
Answers the question: Should the current divided codetape be mutated?
Specified by:
divideShouldBeMutated in interface Environment

shouldBeInserted

public boolean shouldBeInserted()
Answers the question: Should the current divided codetape be inserted extra instructions?
Specified by:
shouldBeInserted in interface Environment

shouldBeDeleted

public boolean shouldBeDeleted()
Answers the question: Should the current divided codetape be deleted one instruction?
Specified by:
shouldBeDeleted in interface Environment

getNeighbourRandomly

public DigitalOrganism getNeighbourRandomly(DigitalOrganism digorg)
Description copied from interface: Environment
Returns one organism of the neighbours of the organism specified by the parameter.
Specified by:
getNeighbourRandomly in interface Environment

getRandom

public java.util.Random getRandom()
Description copied from interface: Environment
The only one random-generator in one Physis-instance should be in the environment. There shouldn't be more than one, otherwise accurate experiment repeat would be impossible.
Specified by:
getRandom in interface Environment