Class Ruletable
java.lang.Object
application.model.rules.ruleloader.Directive
application.model.rules.ruleloader.RuleDirective
application.model.rules.ruleloader.ruletable.Ruletable
public class Ruletable extends RuleDirective
Implements Golly ruletables with addition features such as unbounded rules and arbitrary neighbourhoods.
See https://github.com/GollyGang/ruletablerepository/wiki.
TODO (Nutshell syntax)
-
Field Summary
-
Constructor Summary
Constructors Constructor Description Ruletable(java.lang.String content)
Constructs the ruletable with the provided content -
Method Summary
Modifier and Type Method Description void
addINTTransitions(INTTransitions transitions1, INTTransitions transitions2, java.lang.String input, java.lang.String output, java.lang.String var0, java.lang.String var1, java.lang.String var2)
Adds isotropic non-totalistic transitions to the ruletablevoid
addINTTransitions(INTTransitions transitions, java.lang.String input, java.lang.String output, java.lang.String var0, java.lang.String var1)
Adds isotropic non-totalistic transitions to the ruletablevoid
addOTTransition(int transition, java.lang.String input, java.lang.String output, java.lang.String var0, java.lang.String var1)
Adds an outer totalistic transition to the ruletablevoid
addOTTransition(java.util.List<java.lang.Integer> transition, java.lang.String input, java.lang.String output, java.util.List<java.lang.String> vars)
Adds an outer totalistic transition with multiple states to the ruletablevoid
addOTTransitions(java.lang.Iterable<java.lang.Integer> transitions, java.lang.String input, java.lang.String output, java.lang.String var0, java.lang.String var1)
Adds outer totalistic transitions to the ruletablevoid
addTransition(java.lang.String transitionLine)
Adds a transition to the ruletablevoid
addVariable(Variable variable)
Adds a variable to the ruletablejava.lang.Object
clone()
Deep copies the directiveCoordinate[]
getNeighbourhood()
This method returns the neighbourhood of a given celljava.util.ArrayList<Transition>
getTransitions()
Gets all the transitions of the ruletablejava.util.Map<java.lang.String,Variable>
getVariables()
Gets all the variables of the ruletableboolean
isPermute()
Is permute symmetry used?void
parseContent(java.lang.String content)
Parses the content of the ruletablevoid
setNeighbourhood(Coordinate[] neighbourhood)
Sets the neighbourhood of the ruletablevoid
setNumStates(int numStates)
Sets the number of states of the ruletablevoid
setPermute()
Enables permute symmetryvoid
setSymmetry(Symmetry symmetry)
Sets the symmetry of the ruletablevoid
setWeights(int[] weights)
Sets the weights of the ruletableint
transitionFunc(int[] neighbours, int cellState)
This method represents the transition function of the rulevoid
updateNeighbourhoodSum()
Updates the neighbourhood sumMethods inherited from class application.model.rules.ruleloader.RuleDirective
getNeighbourhood, getNumStates, getStateWeights, getSymmetry, getTiling, getTiling, getWeights
-
Field Details
-
Constructor Details
-
Ruletable
public Ruletable(java.lang.String content)Constructs the ruletable with the provided content- Parameters:
content
- Content of the ruletable
-
-
Method Details
-
parseContent
public void parseContent(java.lang.String content) throws java.lang.IllegalArgumentExceptionParses the content of the ruletable- Specified by:
parseContent
in classDirective
- Parameters:
content
- The content of the ruletable- Throws:
java.lang.IllegalArgumentException
- Thrown when the ruletable inputted is invalid
-
getNeighbourhood
Description copied from class:RuleDirective
This method returns the neighbourhood of a given cell- Specified by:
getNeighbourhood
in classRuleDirective
- Returns:
- A list of Coordinates that represent the neighbourhood
-
transitionFunc
public int transitionFunc(int[] neighbours, int cellState)Description copied from class:RuleDirective
This method represents the transition function of the rule- Specified by:
transitionFunc
in classRuleDirective
- Parameters:
neighbours
- The cell's neighbours in the order of the neighbourhood providedcellState
- The current state of the cell- Returns:
- The state of the cell in the next generation
-
clone
public java.lang.Object clone()Description copied from class:Directive
Deep copies the directive -
addVariable
Adds a variable to the ruletable- Parameters:
variable
- The variable to be added
-
addTransition
public void addTransition(java.lang.String transitionLine)Adds a transition to the ruletable- Parameters:
transitionLine
- The string representing the transition
-
addOTTransition
public void addOTTransition(int transition, java.lang.String input, java.lang.String output, java.lang.String var0, java.lang.String var1)Adds an outer totalistic transition to the ruletable- Parameters:
transition
- The transition to add to the ruletableinput
- The input state / variableoutput
- The output state / variablevar0
- The state / variable that represents state 0var1
- The state / variable that represents state 1
-
addOTTransition
public void addOTTransition(java.util.List<java.lang.Integer> transition, java.lang.String input, java.lang.String output, java.util.List<java.lang.String> vars)Adds an outer totalistic transition with multiple states to the ruletable- Parameters:
transition
- The transition to add to the ruletableinput
- The input state / variableoutput
- The output state / variablevars
- The variables that represent each state
-
addOTTransitions
public void addOTTransitions(java.lang.Iterable<java.lang.Integer> transitions, java.lang.String input, java.lang.String output, java.lang.String var0, java.lang.String var1)Adds outer totalistic transitions to the ruletable- Parameters:
transitions
- The transitions to add to the ruletableinput
- The input state / variableoutput
- The output state / variablevar0
- The state / variable that represents state 0var1
- The state / variable that represents state 1
-
addINTTransitions
public void addINTTransitions(INTTransitions transitions, java.lang.String input, java.lang.String output, java.lang.String var0, java.lang.String var1)Adds isotropic non-totalistic transitions to the ruletable- Parameters:
transitions
- The transitions to add to the ruletableinput
- The input state / variableoutput
- The output state / variablevar0
- The state / variable that represents state 0var1
- The state / variable that represents state 1
-
addINTTransitions
public void addINTTransitions(INTTransitions transitions1, INTTransitions transitions2, java.lang.String input, java.lang.String output, java.lang.String var0, java.lang.String var1, java.lang.String var2)Adds isotropic non-totalistic transitions to the ruletable- Parameters:
transitions1
- The 1st transition to add to the ruletabletransitions2
- The 2nd transition to add to the ruletableinput
- The input state / variableoutput
- The output state / variablevar0
- The state / variable that represents state 0var1
- The state / variable that represents state 1var2
- The state / variable that represents state 2
-
setPermute
public void setPermute()Enables permute symmetry -
isPermute
public boolean isPermute()Is permute symmetry used?- Returns:
- True if permute symmetry is used, false otherwise
-
setSymmetry
Sets the symmetry of the ruletable- Parameters:
symmetry
- The symmetry of the ruletable
-
setNumStates
public void setNumStates(int numStates)Sets the number of states of the ruletable- Parameters:
numStates
- The number of states of the ruletable
-
setWeights
public void setWeights(int[] weights)Sets the weights of the ruletable- Parameters:
weights
- The weights of the ruletable
-
setNeighbourhood
Sets the neighbourhood of the ruletable- Parameters:
neighbourhood
- The neighbourhood of the ruletable
-
updateNeighbourhoodSum
public void updateNeighbourhoodSum()Updates the neighbourhood sum -
getVariables
Gets all the variables of the ruletable- Returns:
- Returns all the variables of the ruletable
-
getTransitions
Gets all the transitions of the ruletable- Returns:
- Returns the transitions of the ruletable
-