life
Class Life

java.lang.Object
  |
  +--life.Life
Direct Known Subclasses:
GBLife

public abstract class Life
extends java.lang.Object

Heavily optimised implementation of Conway's Life genetic algorithim. This version includes loop invariant, loop reversal, and local caching optimisations that are normally the responsibility of the compiler.


Field Summary
protected  byte[][] age
          Age of this cell.
protected  byte[][] count
          Number of alive neighbours
protected  int dx
          Dimensions of the field, minus 1
protected  int dy
          Dimensions of the field, minus 1
 
Constructor Summary
Life(int dx, int dy)
          Create a new Life board with the given width and height
 
Method Summary
protected  void countNeighbours()
          Scan the current board and compute the neighbour count.
protected  void evolve()
          Evolve the cells on the board based on the neighbour count.
protected abstract  void render()
          Implemented by the sub class to render the board
protected  void update()
          Scans the board, updating the neighbours count and computes the next board.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

count

protected final byte[][] count
Number of alive neighbours

age

protected final byte[][] age
Age of this cell. 0 is currently dead.

dx

protected final int dx
Dimensions of the field, minus 1

dy

protected final int dy
Dimensions of the field, minus 1
Constructor Detail

Life

public Life(int dx,
            int dy)
Create a new Life board with the given width and height
Method Detail

render

protected abstract void render()
Implemented by the sub class to render the board

countNeighbours

protected final void countNeighbours()
Scan the current board and compute the neighbour count.

evolve

protected final void evolve()
Evolve the cells on the board based on the neighbour count.

update

protected final void update()
Scans the board, updating the neighbours count and computes the next board.