ec.app.majority
Class CA
- java.lang.Object
-
- ec.app.majority.CA
-
- All Implemented Interfaces:
- java.io.Serializable
public class CA extends java.lang.Object implements java.io.SerializableCA.java Implements a 1-dimensional toroidal CA for purposes of doing the binary majority classification problem. You need to supply the automaton size and the rule neighborhood size at constructor time. The CA itself consists of an array of integers, each 0 or 1. You can clear this array, set it to preset values, or randomize it. You provide the rule as an array of ints, all 0 or 1 as well. The rules are specified in the following order. Let's say that you have a neighborhood of 3, consiting of cells LCR, where L is the cell "left" of the target cell (left is less than, right is greater than). Then the order of the rules are for the neighborhoods 0: 000, 1: 001, 2: 010, 3: 011, 4: 100, 5: 101, 6: 110, 7: 111. In other words, the neighborhood is interpreted as a binary number and that's the index into the rule.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description CA(int width, int neighborhood)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidclear(boolean toOnes)booleanconverged()int[]getRule()int[]getVals()voidrandomize(EvolutionState state, int thread)voidsetRule(int[] r)voidsetVals(int[] vals)voidstep(int steps, boolean stopWhenConverged)
-
-
-
Method Detail
-
getVals
public int[] getVals()
-
getRule
public int[] getRule()
-
setRule
public void setRule(int[] r)
-
setVals
public void setVals(int[] vals)
-
clear
public void clear(boolean toOnes)
-
converged
public final boolean converged()
-
randomize
public void randomize(EvolutionState state, int thread)
-
step
public void step(int steps, boolean stopWhenConverged)
-
-
DMelt 3.0 © DataMelt by jWork.ORG