Package application.model.rules
Class RuleFamily
java.lang.Object
application.model.rules.Rule
application.model.rules.RuleFamily
- All Implemented Interfaces:
java.lang.Cloneable
- Direct Known Subclasses:
AlternatingRule,BaseHROT,BaseINT,Euclidean,Margolus,OneDimensional,RuleLoader,Turmites
public abstract class RuleFamily extends Rule implements java.lang.Cloneable
Represents a family of rules or a rulespace
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.StringnameName of the Rule Family (displayed in the RuleDialog)protected java.lang.StringrulestringRulestring of the Rule FamilyFields inherited from class application.model.rules.Rule
alternatingPeriod, background, boundedGrid, numStates, readingOrder, tiling -
Constructor Summary
Constructors Constructor Description RuleFamily() -
Method Summary
Modifier and Type Method Description abstract java.lang.Stringcanonise(java.lang.String rulestring)Canonises the inputted rulestring with the currently loaded parameters.abstract java.lang.Objectclone()Clones the objectbooleanequals(java.lang.Object o)protected abstract voidfromRulestring(java.lang.String rulestring)Loads the rule's parameters from a rulestringjava.lang.String[]generateComments()Generates comments that will be placed in the RLE.abstract java.lang.StringgetDescription()Returns a plain text description of the rule family to be displayed in the Rule Dialogjava.lang.StringgetName()Gets the name of the ruleprotected java.util.ArrayList<int[]>getNeighbourList(Grid[] grids)Gets the list of neighbours with the input state and output state at the first and last index respectively when provided with an evolutionary sequence.abstract java.lang.String[]getRegex()The regexes that will match a valid rulestringjava.util.Map<java.lang.String,java.lang.String>getRuleInfo()Gets information about the rulejava.lang.StringgetRulestring()Gets the rulestring of the ruleinthashCode()voidloadComments(java.lang.String[] comments)Loads the additional information stored in the comments generated by generateComments An empty array maybe passed in (meaning no comments)voidsetRulestring(java.lang.String rulestring)Sets the rulestring of the rule family to the inputted valuejava.lang.StringtoString()voidupdateBackground()Updates the background of the rule based on the loaded parameters.Methods inherited from class application.model.rules.Rule
convertState, dependsOnNeighbours, getAlternatingPeriod, getBoundedGrid, getColour, getName, getNeighbourhood, getNeighbourhood, getNumStates, getTiling, setBackground, setBoundedGrid, setReadingOrder, step, transitionFunc
-
Field Details
-
name
protected java.lang.String nameName of the Rule Family (displayed in the RuleDialog) -
rulestring
protected java.lang.String rulestringRulestring of the Rule Family
-
-
Constructor Details
-
RuleFamily
public RuleFamily()
-
-
Method Details
-
fromRulestring
protected abstract void fromRulestring(java.lang.String rulestring)Loads the rule's parameters from a rulestring- Parameters:
rulestring- The rulestring of the rule (eg. B3/S23, R2,C2,S5-9,B7-8,NM)- Throws:
java.lang.IllegalArgumentException- Thrown if an invalid rulestring is passed in
-
canonise
public abstract java.lang.String canonise(java.lang.String rulestring)Canonises the inputted rulestring with the currently loaded parameters. This method should be called whenever the parameters of a rule are updated.- Parameters:
rulestring- The rulestring to canonised- Returns:
- Canonised rulestring
-
setRulestring
public void setRulestring(java.lang.String rulestring)Sets the rulestring of the rule family to the inputted value- Parameters:
rulestring- Rulestring of the rule
-
updateBackground
public void updateBackground()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}. -
getRegex
public abstract java.lang.String[] getRegex()The regexes that will match a valid rulestring- Returns:
- An array of regexes that will match a valid rulestring
-
getDescription
public abstract java.lang.String getDescription()Returns a plain text description of the rule family to be displayed in the Rule Dialog- Returns:
- Description of the rule family
-
getRuleInfo
public java.util.Map<java.lang.String,java.lang.String> getRuleInfo()Gets information about the rule- Returns:
- Returns information about the rule in a map
-
generateComments
public java.lang.String[] generateComments()Generates comments that will be placed in the RLE. These comments represent additional information that is not stored in the rulestring (e.g. weights)- Returns:
- An array of comments each starting with "#R" (eg. {"#R 1 2 3 2 1", "#R 2 4 6 4 2"}). If no additional information needs to be added return null or an empty string array.
-
loadComments
public void loadComments(java.lang.String[] comments)Loads the additional information stored in the comments generated by generateComments An empty array maybe passed in (meaning no comments)- Parameters:
comments- The comments from the RLE (all starting with #R)
-
clone
public abstract java.lang.Object clone()Clones the object- Overrides:
clonein classjava.lang.Object- Returns:
- A deepcopy of the object
-
getName
public java.lang.String getName()Gets the name of the rule- Returns:
- Name of the rule
-
getRulestring
public java.lang.String getRulestring()Gets the rulestring of the rule- Returns:
- Rulestring of the rule
-
toString
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-
getNeighbourList
Gets the list of neighbours with the input state and output state at the first and last index respectively when provided with an evolutionary sequence. Should be used in conjuction with getMinMaxRule.- Parameters:
grids- An array of grids representing an evolutionary sequence- Returns:
- Returns the list of neighbours
-
equals
public boolean equals(java.lang.Object o)- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()- Overrides:
hashCodein classjava.lang.Object
-