physis.core.virtualmachine
Interface GeneticCodeTape

All Superinterfaces:
CodeTape
All Known Implementing Classes:
SoupGeneticCodeTape, CellGeneticCodeTape

public interface GeneticCodeTape
extends CodeTape

The abstraction of the genetic code. It remains a circular tape with assembly like instructions and operands on it but it has some biological features needed for cell-division like processes, activity registration and other access functions. !!It should be a common interface for both soup and cell-like codetapes!!


Field Summary
static byte COPIED
          Instruction-attribute: the instruction is a copied one.
static byte EXECUTED
          Instruction-attribute: the instruction is executed at least once.
static byte EXECUTED_OR_COPIED
          Instruction-attribute: the instruction is executed or copied.
static byte MUTATED
          Instruction-attribute: the instruction was mutated.
 
Method Summary
 void allocate(int numberof_newcells)
          It's a biological operator.
 boolean blockCopy(int source, int destination, int length)
          Copies an instruction from source position to destination position.
 int calculateEffectiveLength()
          The effective length can be calculated by the number of executed instructions.
 void clearExecutedFlag(int position)
           
 boolean contains(short instcode)
          Returns true if the codetape contains the specified instruction.
 boolean copy(int source, int destination)
          Copies an instruction from source position to destination position.
 void delete()
          Removes an instruction from a random position.
 GeneticCodeTape divide()
          It divides the codetape.
 short fetchInst(int position)
          Simply returns the instruction or operand on the specified position.
 Genome getChildGenome()
          Returns the genetic information from the child-codetape.
 Genome getGenome()
          Returns the genetic information from the codetape.
 int getSize()
          Returns the absolute size of the codetape.(number of contained instructions)
 void insert()
          Inserts an instruction on a random position.
 boolean isAllocated()
          Returns true if the cell already allocated space for the spawn.
 boolean isAllocationPossible(int numberof_newcells)
          The size must be in a predefined range, otherwise the allocation fails.
 boolean isCopied(int position)
          Answers the question: is the positionth instruction copied?
 boolean isExecuted(int position)
          Answers the question: is the positionth instruction executed?
 boolean isMutated(int position)
          Answers the question: is the positionth instruction mutated?
 boolean isProliferationPossible()
          Checks whether the organism is able to spawn (are there enough copied instructions?).
 void mutate(int position)
          Mutate the specified instruction.
 
Methods inherited from interface physis.core.virtualmachine.CodeTape
read, write
 

Field Detail

EXECUTED

public static final byte EXECUTED
Instruction-attribute: the instruction is executed at least once.

COPIED

public static final byte COPIED
Instruction-attribute: the instruction is a copied one.

MUTATED

public static final byte MUTATED
Instruction-attribute: the instruction was mutated.

EXECUTED_OR_COPIED

public static final byte EXECUTED_OR_COPIED
Instruction-attribute: the instruction is executed or copied.
Method Detail

fetchInst

public short fetchInst(int position)
Simply returns the instruction or operand on the specified position.
The position becomes EXECUTED.
This method isn't failsafe like read and write. The virtualmachine has to take care of the proper position. It provides only quick access for the executable part of the code.

isAllocationPossible

public boolean isAllocationPossible(int numberof_newcells)
The size must be in a predefined range, otherwise the allocation fails.

allocate

public void allocate(int numberof_newcells)
It's a biological operator. This should happen before the cell division. (making room, preparating or something like that) CELL: It allocates instruction cells at the end of the codetape. One allocation may occur between divides. It also allocates the information arrays (iscopied...etc.) SOUP: Because of the one large memory pool (soup) there's no space allocation. In this case it's only the declaration of the size of the code block to be copied.

isAllocated

public boolean isAllocated()
Returns true if the cell already allocated space for the spawn.

isProliferationPossible

public boolean isProliferationPossible()
Checks whether the organism is able to spawn (are there enough copied instructions?).

divide

public GeneticCodeTape divide()
It divides the codetape. The Environment is responsible for palcing the child, the codetape only returns an other one.

contains

public boolean contains(short instcode)
Returns true if the codetape contains the specified instruction.
Parameters:
instcode - The searched instruction.

isMutated

public boolean isMutated(int position)
Answers the question: is the positionth instruction mutated?

isCopied

public boolean isCopied(int position)
Answers the question: is the positionth instruction copied?

isExecuted

public boolean isExecuted(int position)
Answers the question: is the positionth instruction executed?

clearExecutedFlag

public void clearExecutedFlag(int position)

mutate

public void mutate(int position)
Mutate the specified instruction.

insert

public void insert()
Inserts an instruction on a random position.

delete

public void delete()
Removes an instruction from a random position.

copy

public boolean copy(int source,
                    int destination)
Copies an instruction from source position to destination position. Returns true if the copy was succesfull.

blockCopy

public boolean blockCopy(int source,
                         int destination,
                         int length)
Copies an instruction from source position to destination position. Returns true if the copy was succesfull.

calculateEffectiveLength

public int calculateEffectiveLength()
The effective length can be calculated by the number of executed instructions. The executed nop instructions don't count.

getSize

public int getSize()
Returns the absolute size of the codetape.(number of contained instructions)
Specified by:
getSize in interface CodeTape

getGenome

public Genome getGenome()
Returns the genetic information from the codetape.

getChildGenome

public Genome getChildGenome()
Returns the genetic information from the child-codetape.