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 voidaddINTTransitions(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 ruletablevoidaddINTTransitions(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 ruletablevoidaddOTTransition(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 ruletablevoidaddOTTransition(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 ruletablevoidaddOTTransitions(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 ruletablevoidaddTransition(java.lang.String transitionLine)Adds a transition to the ruletablevoidaddVariable(Variable variable)Adds a variable to the ruletablejava.lang.Objectclone()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 ruletablebooleanisPermute()Is permute symmetry used?voidparseContent(java.lang.String content)Parses the content of the ruletablevoidsetNeighbourhood(Coordinate[] neighbourhood)Sets the neighbourhood of the ruletablevoidsetNumStates(int numStates)Sets the number of states of the ruletablevoidsetPermute()Enables permute symmetryvoidsetSymmetry(Symmetry symmetry)Sets the symmetry of the ruletablevoidsetWeights(int[] weights)Sets the weights of the ruletableinttransitionFunc(int[] neighbours, int cellState)This method represents the transition function of the rulevoidupdateNeighbourhoodSum()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:
parseContentin classDirective- Parameters:
content- The content of the ruletable- Throws:
java.lang.IllegalArgumentException- Thrown when the ruletable inputted is invalid
-
getNeighbourhood
Description copied from class:RuleDirectiveThis method returns the neighbourhood of a given cell- Specified by:
getNeighbourhoodin classRuleDirective- Returns:
- A list of Coordinates that represent the neighbourhood
-
transitionFunc
public int transitionFunc(int[] neighbours, int cellState)Description copied from class:RuleDirectiveThis method represents the transition function of the rule- Specified by:
transitionFuncin 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:DirectiveDeep 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
-