|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.generation5.bio.CellularAutomata
org.generation5.bio.CellularAutomataLayered
Expands upon the cellular automata class by adding a separate layer of automata that are independent of the world states. This is useful for classes that require a greater degree of interaction with the world. For example, each cell in Conway's Life simply requires knowledge of its 8 immediate neighbours, and does not move location. Other, more complicated, CAs move about and must keep internal states as well as world states. Termites are a good example of this, where the world and the woodchips are independent of the termites.
CellularAutomata,
ConwaysLifeCA,
TermitesCA| Field Summary | |
protected java.awt.Color[] |
clrStates
The colours representing the automaton states. |
protected boolean |
collisionDetection
Collision detection can be used for CellularAutomataLayered-derived
classes to ensure that two agents do not occupy the same world position. |
protected boolean[][] |
positionTest
Stores boolean values corresponding to cell occupancy. |
| Fields inherited from class org.generation5.bio.CellularAutomata |
bufferPosition, bufferSize, caSize, caWorld, caWorld_x, caWorld_y, clrBackground, clrGrid, clrWorld, DOUBLE_BUFFERING, doubleBuffering, drawGrid, ENCLOSED, geometryType, INFINITE, TORODIAL, X_AXIS, Y_AXIS |
| Constructor Summary | |
CellularAutomataLayered()
Default constructor. |
|
CellularAutomataLayered(int size_x,
int size_y)
Create an instance of CellularAutomataLayered with world
size information. |
|
CellularAutomataLayered(int size_x,
int size_y,
int options)
Create a new instance of CellularAutomataLayered with positional
information and optional settings. |
|
| Method Summary | |
void |
addAutomaton(CAAgent agent)
Adds an automaton of type CAAgent. |
void |
addAutomaton(int pos_x,
int pos_y,
int state)
Add an automaton to the world with state and position information. |
CAAgent |
getCA(int caIndex)
Retrieve the corresponding CAAgent, which in turn holds positional,
state and other information. |
boolean |
getCollisionDetection()
Returns the collision detection status of this cellular automata world. |
int |
getNumCAs()
Retrieve the number of automata in the world, this should be equal to the number of calls to addAutomaton. |
protected boolean |
isCellFree(int x,
int y)
Check to see if a world cell is free or not. |
void |
moveCAAbsolute(int caIndex,
int new_x,
int new_y)
Move a given automaton to a new position. |
void |
moveCARelative(int caIndex,
int dx,
int dy)
Move a given automaton to a new position relative to its current. |
void |
removeAll()
Remove all the automata from the world. |
void |
render(java.awt.Graphics graphics,
int pw,
int ph)
Draws the world state, then each automata. |
void |
setCollisionDetection(boolean cd)
Set or reset collision detection in the world. |
void |
setStateColour(int state,
java.awt.Color colour)
Sets the colour of the automata states. |
void |
setWorldSize(int size_x,
int size_y)
Sets the world size. |
| Methods inherited from class org.generation5.bio.CellularAutomata |
clearWorld, doStep, drawGrid, flipBuffer, getBackgroundColor, getCASize, getGeometry, getSizeX, getSizeY, getWorldAt, init, iterateCA, iterateCA, reset, setBackgroundColor, setCASize, setGeometry, setWorldAt, setWorldAtEx, setWorldAtRelative, setWorldColors, setWorldColour, translateGeometry, writeImage |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected boolean[][] positionTest
protected boolean collisionDetection
CellularAutomataLayered-derived
classes to ensure that two agents do not occupy the same world position.
Collision detection is turned off by default.
protected java.awt.Color[] clrStates
| Constructor Detail |
public CellularAutomataLayered()
CellularAutomata.CellularAutomata(int, int)
public CellularAutomataLayered(int size_x,
int size_y)
CellularAutomataLayered with world
size information. Only two world colours are set, state 0 to black and
state 1 to red.
size_x - the world x-size.size_y - the world y-size.
public CellularAutomataLayered(int size_x,
int size_y,
int options)
CellularAutomataLayered with positional
information and optional settings.
size_x - the x-size of the world.size_y - the y-size of the world.options - additional options.| Method Detail |
public void setWorldSize(int size_x,
int size_y)
size_x * size_y.
setWorldSize in class CellularAutomatasize_x - the world x-size.size_y - the world y-size.CellularAutomata.setWorldSize(int, int)public void setCollisionDetection(boolean cd)
cd - turn collision detection on or off.public boolean getCollisionDetection()
protected boolean isCellFree(int x,
int y)
translateGeometry before accessing the positionTest array.
x - the x-position to check.y - the y-position to check.
positionTest.
public void addAutomaton(int pos_x,
int pos_y,
int state)
pos_x - the x-position of the new automatonpos_y - the y-position of the new automatonstate - the state of the new automatonpublic void addAutomaton(CAAgent agent)
CAAgent. This allows you to add
CAAgent-derived classes (such as DirectedCAAgent) to the world.
Remember to initialize parameters such as positional and state information.
agent - the agent to add.CAAgentpublic void removeAll()
public void moveCARelative(int caIndex,
int dx,
int dy)
(x,y), then the new position is
(x+dx, y+dy).
caIndex - the index of the automaton to move.dx - x-delta position.dy - y-delta position.
public void moveCAAbsolute(int caIndex,
int new_x,
int new_y)
(x,y), then the new position is
(new_x, new_y).
caIndex - the index of the automaton to move.new_x - the new x-position.new_y - the new y-position.public CAAgent getCA(int caIndex)
CAAgent, which in turn holds positional,
state and other information.
caIndex - the index of the automaton to return.
CAAgentpublic int getNumCAs()
addAutomaton.
addAutomaton(int, int, int)
public void render(java.awt.Graphics graphics,
int pw,
int ph)
render in interface Visualizablerender in class CellularAutomatagraphics - the graphics context.pw - the width of the context.ph - the height of the context.CellularAutomata.caSize
public void setStateColour(int state,
java.awt.Color colour)
setWorldColour.
state - the state index (0-255).colour - the colour of the state.
|
This documentation is part of the Generation5 JDK.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||