Class Turmites
java.lang.Object
application.model.rules.Rule
application.model.rules.RuleFamily
application.model.rules.misc.turmites.Turmites
- All Implemented Interfaces:
java.lang.Cloneable
public class Turmites extends RuleFamily
Represents a 2D turing machine or a turmite
-
Field Summary
Fields inherited from class application.model.rules.Rule
alternatingPeriod, background, boundedGrid, numStates, readingOrder, tiling
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description java.lang.String
canonise(java.lang.String rulestring)
Canonises the inputted rulestring with the currently loaded parameters.java.lang.Object
clone()
Clones the objectprotected void
fromRulestring(java.lang.String rulestring)
Loads the rule's parameters from a rulestringjavafx.scene.paint.Color
getColour(int state)
Returns the colour of a cell of the provided statejava.lang.String
getDescription()
Returns a plain text description of the rule family to be displayed in the Rule DialogCoordinate[]
getNeighbourhood(int generation)
This method returns the neighbourhood of a given cell at a certain generationjava.lang.String[]
getRegex()
The regexes that will match a valid rulestringint
transitionFunc(int[] neighbours, int cellState, int generations, Coordinate coordinate)
This method represents the transition function of the rulevoid
updateBackground()
Updates the background of the rule based on the loaded parameters.Methods inherited from class application.model.rules.RuleFamily
equals, generateComments, getName, getNeighbourList, getRuleInfo, getRulestring, hashCode, loadComments, setRulestring, toString
Methods inherited from class application.model.rules.Rule
convertState, dependsOnNeighbours, getAlternatingPeriod, getBoundedGrid, getName, getNeighbourhood, getNumStates, getTiling, setBackground, setBoundedGrid, setReadingOrder, step
-
Constructor Details
-
Method Details
-
fromRulestring
protected void fromRulestring(java.lang.String rulestring)Description copied from class:RuleFamily
Loads the rule's parameters from a rulestring- Specified by:
fromRulestring
in classRuleFamily
- Parameters:
rulestring
- The rulestring of the rule (eg. B3/S23, R2,C2,S5-9,B7-8,NM)
-
canonise
public java.lang.String canonise(java.lang.String rulestring)Description copied from class:RuleFamily
Canonises the inputted rulestring with the currently loaded parameters. This method should be called whenever the parameters of a rule are updated.- Specified by:
canonise
in classRuleFamily
- Parameters:
rulestring
- The rulestring to canonised- Returns:
- Canonised rulestring
-
updateBackground
public void updateBackground()Description copied from class:RuleFamily
Updates the background of the rule based on the loaded parameters. This method should be called whenever the parameters of a rule are updated. For non-strobing rules, the background is {0}.- Overrides:
updateBackground
in classRuleFamily
-
getRegex
public java.lang.String[] getRegex()Description copied from class:RuleFamily
The regexes that will match a valid rulestring- Specified by:
getRegex
in classRuleFamily
- Returns:
- An array of regexes that will match a valid rulestring
-
getDescription
public java.lang.String getDescription()Description copied from class:RuleFamily
Returns a plain text description of the rule family to be displayed in the Rule Dialog- Specified by:
getDescription
in classRuleFamily
- Returns:
- Description of the rule family
-
clone
public java.lang.Object clone()Description copied from class:RuleFamily
Clones the object- Specified by:
clone
in classRuleFamily
- Returns:
- A deepcopy of the object
-
getNeighbourhood
Description copied from class:Rule
This method returns the neighbourhood of a given cell at a certain generation- Specified by:
getNeighbourhood
in classRule
- Parameters:
generation
- The generation of the simulation- Returns:
- A list of Coordinates that represent the neighbourhood
-
transitionFunc
Description copied from class:Rule
This method represents the transition function of the rule- Specified by:
transitionFunc
in classRule
- Parameters:
neighbours
- The cell's neighbours in the order of the neighbourhood providedcellState
- The current state of the cellgenerations
- The current generation of the simulationcoordinate
- The coordinate of the cell- Returns:
- The state of the cell in the next generation
-
getColour
public javafx.scene.paint.Color getColour(int state)Description copied from class:Rule
Returns the colour of a cell of the provided state
-