|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectAbstract1DGrid
CA
This cellular automata (CA) is a grid of cells, particularly its states. This
implementation is 1 dimensional.
State can be true
=1 or false
=0.
Field Summary | |
private boolean[] |
ca
Array of cell states. |
Fields inherited from class Abstract1DGrid |
|
Constructor Summary | |
CA(boolean[] states)
Creates CA with the given cell states. |
|
CA(int size)
Creates CA with the specified size. |
Method Summary | |
static CA |
generateRandomCA(int size,
double onesRatio)
Generates a CA with random cell states considering the ratio of 1s that occur in the CA. |
boolean |
get(int index)
|
boolean |
getLeft(int index)
|
boolean |
getRight(int index)
|
boolean |
moreOnes()
|
boolean |
moreZeros()
|
int |
onesCount()
|
double |
onesRatio()
|
void |
set(int index,
boolean state)
Sets the state of the cell. |
java.lang.String |
toString()
|
int |
zerosCount()
|
double |
zerosRatio()
|
Methods inherited from class Abstract1DGrid |
getLeftIndex, getRightIndex, size |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
private boolean[] ca
Constructor Detail |
public CA(int size)
CA
with the specified size. All cell states are set
to 0 (false
).
size
- the CA size.public CA(boolean[] states)
CA
with the given cell states.
states
- the cell states (null
not permitted).Method Detail |
public static CA generateRandomCA(int size, double onesRatio)
size
- the CA size.onesRatio
- the ratio of 1s that occur in the CA beside the 0s.
null
not possible).public boolean get(int index)
index
- the cell index.
public void set(int index, boolean state)
index
- the cell index.state
- the cell new state.public boolean getLeft(int index)
index
- the cell index.
public boolean getRight(int index)
index
- the cell index.
public int onesCount()
true
states) in the CA.public double onesRatio()
true
states) according to 0s in
the CA.public boolean moreOnes()
true
if CA has more or equal half 1s (true
states) according to 0s.public int zerosCount()
false
states) in the CA.public double zerosRatio()
false
states) according to 1s in
the CA.public boolean moreZeros()
true
if CA has more or equal half 0s (false
states) according to 1s.public java.lang.String toString()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |