|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--physis.core.virtualmachine.CellGeneticCodeTape
Cell-like implementations of the genetic codetape. For each organism there's a separated cell. (Avida-like)
| Field Summary | |
private boolean |
alreadyallocated
It's a flag which indicates whether an allocation has happened or not. |
private byte[] |
attributes
Each byte represents the attributes of an instruction. |
private static short |
blank_inst
|
private short[] |
child
When the organism is pregnant the child's code is being developed here. |
private byte[] |
childattributes
|
private static InstructionSet |
instruction_set
|
private short[] |
memory
The instructions are represented with a thin class called InstructionCode. |
| Fields inherited from interface physis.core.virtualmachine.GeneticCodeTape |
COPIED, EXECUTED, EXECUTED_OR_COPIED, MUTATED |
| Constructor Summary | |
(package private) |
CellGeneticCodeTape(short[] instructions,
byte[] attribs)
Creates codetape from instructionarray. |
|
CellGeneticCodeTape(java.lang.String filename)
It reads the instructions from a file.The first organism is created this way.(One instruction per line, lines beginning with # are discarded. |
| 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 cell to destination cell. |
void |
delete()
Removes an instruction from a random position. |
GeneticCodeTape |
divide()
It divides the codetape. |
short |
fetchInst(int position)
Just returns the value without checking. |
Genome |
getChildGenome()
Returns the genetic information from the codetape. |
Genome |
getGenome()
Returns the genetic information from the codetape. |
private int |
getNumberOfCopiedInstructionsInChild()
|
static GeneticCodeTape |
getRandomTape(int length)
|
int |
getSize()
Returns the size of the codetape. |
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. |
void |
mutate(int position)
Mutate the specified instruction. |
short |
read(int position)
It gives the instruction on the specified position. |
java.lang.String |
toString()
Returns the string representation of the codetape. |
void |
write(int position,
short new_value)
The position is mapped into the proper range. |
| Methods inherited from class java.lang.Object |
|
| Field Detail |
private static InstructionSet instruction_set
private static short blank_inst
private short[] memory
private short[] child
private boolean alreadyallocated
private byte[] attributes
private byte[] childattributes
| Constructor Detail |
public CellGeneticCodeTape(java.lang.String filename)
CellGeneticCodeTape(short[] instructions,
byte[] attribs)
| Method Detail |
public short read(int position)
read in interface CodeTape
public void write(int position,
short new_value)
write in interface CodeTapepublic short fetchInst(int position)
fetchInst in interface GeneticCodeTapepublic void allocate(int numberof_newcells)
allocate in interface GeneticCodeTapepublic boolean isAllocated()
GeneticCodeTapeisAllocated in interface GeneticCodeTapepublic boolean isProliferationPossible()
isProliferationPossible in interface GeneticCodeTapepublic boolean isAllocationPossible(int numberof_newcells)
GeneticCodeTapeisAllocationPossible in interface GeneticCodeTapepublic GeneticCodeTape divide()
divide in interface GeneticCodeTapepublic boolean contains(short instcode)
contains in interface GeneticCodeTapeinstcode - The searched instruction.public boolean isMutated(int position)
isMutated in interface GeneticCodeTapepublic boolean isCopied(int position)
GeneticCodeTapeisCopied in interface GeneticCodeTapepublic boolean isExecuted(int position)
GeneticCodeTapeisExecuted in interface GeneticCodeTapepublic void clearExecutedFlag(int position)
clearExecutedFlag in interface GeneticCodeTapepublic void mutate(int position)
mutate in interface GeneticCodeTapepublic void insert()
insert in interface GeneticCodeTapepublic void delete()
delete in interface GeneticCodeTape
public boolean copy(int source,
int destination)
copy in interface GeneticCodeTape
public boolean blockCopy(int source,
int destination,
int length)
GeneticCodeTapeblockCopy in interface GeneticCodeTapepublic int calculateEffectiveLength()
calculateEffectiveLength in interface GeneticCodeTapepublic int getSize()
getSize in interface GeneticCodeTapepublic Genome getGenome()
getGenome in interface GeneticCodeTapepublic Genome getChildGenome()
getChildGenome in interface GeneticCodeTapepublic static GeneticCodeTape getRandomTape(int length)
public java.lang.String toString()
toString in class java.lang.Objectprivate int getNumberOfCopiedInstructionsInChild()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||