physis.core.lifespace
Class Lattice2DLifeSpace

java.lang.Object
  |
  +--physis.core.lifespace.Lattice2DLifeSpace
All Implemented Interfaces:
CellLifeSpace, LifeSpace

public class Lattice2DLifeSpace
extends java.lang.Object
implements CellLifeSpace

dependency: Array2DDigitalOrganismIterator, ArrayDigitalOrganismIterator


Field Summary
private  DigitalOrganism[][] lifespace
           
private  ArrayDigitalOrganismIterator neighbour_iterator
           
private  DigitalOrganism[] neighbours
           
private  java.util.Random rnd
           
private  int x_size
           
private static java.lang.String X_SIZE
           
private  int y_size
           
private static java.lang.String Y_SIZE
           
 
Constructor Summary
Lattice2DLifeSpace()
          Creates a lifespace.
Lattice2DLifeSpace(int x_size_, int y_size_)
          Creates a lifespace with different with dimension x * y.
 
Method Summary
 DigitalOrganismIterator getAllOrganisms()
          This method provides all the organisms of the lifespace.
 DigitalOrganismIterator getNeighbours(DigitalOrganism digorg)
          This method gives the neighbours of an organism.
 DigitalOrganism getOrganismRandomly()
          Gives an organism randomly from the entire 'soup'.
 DigitalOrganismIterator getRegion(double percentage)
          Returns organisms from a connected local territory in the lifespace.
 int getSize()
          Gives the capacity of the lifespace.
 DigitalOrganismIterator getSomeOrganisms(double percentage)
          Returns some organisms.
 void injectGenome(GeneticCodeTape ct)
          Injects the genome into the soup.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

X_SIZE

private static final java.lang.String X_SIZE

Y_SIZE

private static final java.lang.String Y_SIZE

x_size

private int x_size

y_size

private int y_size

lifespace

private DigitalOrganism[][] lifespace

neighbours

private DigitalOrganism[] neighbours

neighbour_iterator

private ArrayDigitalOrganismIterator neighbour_iterator

rnd

private java.util.Random rnd
Constructor Detail

Lattice2DLifeSpace

public Lattice2DLifeSpace()
Creates a lifespace. The dimensional parameters are got from Configuration.

Lattice2DLifeSpace

public Lattice2DLifeSpace(int x_size_,
                          int y_size_)
Creates a lifespace with different with dimension x * y.
Method Detail

injectGenome

public void injectGenome(GeneticCodeTape ct)
Injects the genome into the soup. The target cell is random.
Specified by:
injectGenome in interface LifeSpace

getAllOrganisms

public DigitalOrganismIterator getAllOrganisms()
This method provides all the organisms of the lifespace. This feature is needed when making the update.
Specified by:
getAllOrganisms in interface LifeSpace

getNeighbours

public DigitalOrganismIterator getNeighbours(DigitalOrganism digorg)
This method gives the neighbours of an organism. This is needed when an organism interact with its neighbourhood. Here the topology is 8-neighbourhood on a toroidal two dimensional lattice.
Specified by:
getNeighbours in interface LifeSpace

getOrganismRandomly

public DigitalOrganism getOrganismRandomly()
Gives an organism randomly from the entire 'soup'. It's needed for point mutations for example.
Specified by:
getOrganismRandomly in interface LifeSpace

getSize

public int getSize()
Gives the capacity of the lifespace.
Specified by:
getSize in interface LifeSpace

getSomeOrganisms

public DigitalOrganismIterator getSomeOrganisms(double percentage)
Description copied from interface: LifeSpace
Returns some organisms. The organisms should be distributed uniformly in the whole lifespace. (Should return always a new iterator.)
Specified by:
getSomeOrganisms in interface LifeSpace
Following copied from interface: physis.core.lifespace.LifeSpace
Parameters:
percentage - The percentage of organisms to be returned.

getRegion

public DigitalOrganismIterator getRegion(double percentage)
Description copied from interface: LifeSpace
Returns organisms from a connected local territory in the lifespace. (Should return always a new iterator.)
Specified by:
getRegion in interface LifeSpace
Following copied from interface: physis.core.lifespace.LifeSpace
Parameters:
percentage - The percentage of organisms to be returned.