Package application.model.rules.hrot
Class HROTBSFKL
java.lang.Object
application.model.rules.Rule
application.model.rules.RuleFamily
application.model.rules.hrot.BaseHROT
application.model.rules.hrot.HROTBSFKL
- All Implemented Interfaces:
ApgtableGeneratable
,MinMaxRuleable
,java.lang.Cloneable
public class HROTBSFKL extends BaseHROT implements ApgtableGeneratable, MinMaxRuleable
Implements the HROT BSFKL rule family
-
Field Summary
Fields inherited from class application.model.rules.hrot.BaseHROT
hrotTransitions, maxNeighbourhoodCount, neighbourhood, neighbourhoodRegex, weights
Fields inherited from class application.model.rules.Rule
alternatingPeriod, background, boundedGrid, numStates, readingOrder, tiling
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description boolean
betweenMinMax(RuleFamily minRule, RuleFamily maxRule)
Checks if the current rule is between the given minimum and maximum rulesjava.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 rulestringRuleDirective[]
generateApgtable()
Generates an apgtable for apgsearch to usejava.util.HashSet<java.lang.Integer>
getBirth()
Gets the birth conditions of the HROT BSFKL rulejava.lang.String
getDescription()
Returns a plain text description of the HROT BSFKL rule family to be displayed in the Rule Dialogjava.util.HashSet<java.lang.Integer>
getForcing()
Gets the forcing conditions of the HROT BSFKL rulejava.util.HashSet<java.lang.Integer>
getKilling()
Gets the killing conditions of the HROT BSFKL rulejava.util.HashSet<java.lang.Integer>
getLiving()
Gets the living conditions of the HROT BSKFL ruleorg.javatuples.Pair<RuleFamily,RuleFamily>
getMinMaxRule(Grid[] grids)
Returns the minimum and maximum rule of the provided evolutionary sequencejava.lang.String[]
getRegex()
The regexes that will match a valid rulestringjava.util.HashSet<java.lang.Integer>
getSurvival()
Gets the survival conditions of the HROT BSFKL rulevoid
randomise(RuleFamily minRule, RuleFamily maxRule)
Randomise the parameters of the current rule to be between minimum and maximum rules Used in CAViewer's rule search programvoid
setBirth(java.util.HashSet<java.lang.Integer> birth)
Sets the birth conditions of the HROT BSFKL rulevoid
setForcing(java.util.HashSet<java.lang.Integer> forcing)
Sets the forcing conditions of the HROT BSFKL rulevoid
setKilling(java.util.HashSet<java.lang.Integer> killing)
Sets the killing conditions of the HROT BSFKL rulevoid
setLiving(java.util.HashSet<java.lang.Integer> living)
Sets the living conditions of the HROT BSFKL rulevoid
setSurvival(java.util.HashSet<java.lang.Integer> survival)
Sets the survival conditions of the HROT BSFKL ruleint
transitionFunc(int[] neighbours, int cellState, int generations, Coordinate coordinate)
This method represents the transition function of the ruleboolean
validMinMax(RuleFamily minRule, RuleFamily maxRule)
Checks if the minimum rule and maximum rules provided are validMethods inherited from class application.model.rules.hrot.BaseHROT
generateComments, getNeighbourhood, getNeighbourhoodSpecifier, getRuleInfo, getWeights, loadComments, loadNeighbourhood, setNeighbourhood, setWeights
Methods inherited from class application.model.rules.RuleFamily
equals, getName, getNeighbourList, getRulestring, hashCode, setRulestring, toString, updateBackground
Methods inherited from class application.model.rules.Rule
convertState, dependsOnNeighbours, getAlternatingPeriod, getBoundedGrid, getColour, getName, getNeighbourhood, getNumStates, getTiling, setBackground, setBoundedGrid, setReadingOrder, step
-
Constructor Details
-
HROTBSFKL
public HROTBSFKL()Creates a HROT BSFKL rule -
HROTBSFKL
public HROTBSFKL(java.lang.String rulestring)Creates a HROT BSFKL rule with the given rulestring- Parameters:
rulestring
- The rulestring of the HROT BSFKL rule to be created- Throws:
java.lang.IllegalArgumentException
- Thrown if the rulestring is invalid
-
-
Method Details
-
fromRulestring
protected void fromRulestring(java.lang.String rulestring)Loads the rule's parameters from a rulestring- Specified by:
fromRulestring
in classRuleFamily
- Parameters:
rulestring
- The rulestring of the HROT rule (eg. B3/S23, R2,C2,S6-9,B7-8,NM)- Throws:
java.lang.IllegalArgumentException
- Thrown if an invalid rulestring is passed in
-
canonise
public java.lang.String canonise(java.lang.String rulestring)Canonises the inputted rulestring with the currently loaded parameters.- Specified by:
canonise
in classRuleFamily
- Parameters:
rulestring
- The rulestring to canonised- Returns:
- Canonised rulestring
-
getRegex
public java.lang.String[] getRegex()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()Returns a plain text description of the HROT BSFKL rule family to be displayed in the Rule Dialog- Specified by:
getDescription
in classRuleFamily
- Returns:
- Description of the HROT BSFKL rule family
-
generateApgtable
Generates an apgtable for apgsearch to use- Specified by:
generateApgtable
in interfaceApgtableGeneratable
- Returns:
- Returns an array of rule directives to be placed in the ruletable
-
randomise
public void randomise(RuleFamily minRule, RuleFamily maxRule) throws java.lang.IllegalArgumentExceptionRandomise the parameters of the current rule to be between minimum and maximum rules Used in CAViewer's rule search program- Specified by:
randomise
in interfaceMinMaxRuleable
- Parameters:
minRule
- The minimum rule for randomisationmaxRule
- The maximum rule for randomisation- Throws:
java.lang.IllegalArgumentException
- Thrown if the minimum and maximum rules are invalid
-
getMinMaxRule
Returns the minimum and maximum rule of the provided evolutionary sequence- Specified by:
getMinMaxRule
in interfaceMinMaxRuleable
- Parameters:
grids
- An array of grids representing the evolutionary sequence- Returns:
- A pair containing the min rule as the first value and the max rule as the second value
-
betweenMinMax
public boolean betweenMinMax(RuleFamily minRule, RuleFamily maxRule) throws java.lang.IllegalArgumentExceptionChecks if the current rule is between the given minimum and maximum rules- Specified by:
betweenMinMax
in interfaceMinMaxRuleable
- Parameters:
minRule
- The minimum rulemaxRule
- The maximum rule- Returns:
- True if the current rule is between minimum and maximum rules and false if the current rule is not between the minimum and maximum rules
- Throws:
java.lang.IllegalArgumentException
- Thrown if the minimum rule and maximum rule are invalid
-
validMinMax
Checks if the minimum rule and maximum rules provided are valid- Specified by:
validMinMax
in interfaceMinMaxRuleable
- Parameters:
minRule
- The minimum rule to checkmaxRule
- The maximum rule to check- Returns:
- True if the minimum and maximum rules are valid and false if the minimum and maximum rules are not valid
-
getBirth
public java.util.HashSet<java.lang.Integer> getBirth()Gets the birth conditions of the HROT BSFKL rule- Returns:
- Returns the birth conditions of the HROT BSFKL rule
-
getSurvival
public java.util.HashSet<java.lang.Integer> getSurvival()Gets the survival conditions of the HROT BSFKL rule- Returns:
- Returns the survival conditions of the HROT BSFKL rule
-
getForcing
public java.util.HashSet<java.lang.Integer> getForcing()Gets the forcing conditions of the HROT BSFKL rule- Returns:
- Returns the forcing conditions of the HROT BSFKL rule
-
getKilling
public java.util.HashSet<java.lang.Integer> getKilling()Gets the killing conditions of the HROT BSFKL rule- Returns:
- Returns the killing conditions of the HROT BSFKL rule
-
getLiving
public java.util.HashSet<java.lang.Integer> getLiving()Gets the living conditions of the HROT BSKFL rule- Returns:
- Returns the living conditions of the HROT BSFKL rule
-
setBirth
public void setBirth(java.util.HashSet<java.lang.Integer> birth)Sets the birth conditions of the HROT BSFKL rule- Parameters:
birth
- The birth conditions
-
setSurvival
public void setSurvival(java.util.HashSet<java.lang.Integer> survival)Sets the survival conditions of the HROT BSFKL rule- Parameters:
survival
- The survival conditions
-
setForcing
public void setForcing(java.util.HashSet<java.lang.Integer> forcing)Sets the forcing conditions of the HROT BSFKL rule- Parameters:
forcing
- The forcing conditions
-
setKilling
public void setKilling(java.util.HashSet<java.lang.Integer> killing)Sets the killing conditions of the HROT BSFKL rule- Parameters:
killing
- The killing conditions
-
setLiving
public void setLiving(java.util.HashSet<java.lang.Integer> living)Sets the living conditions of the HROT BSFKL rule- Parameters:
living
- The living conditions
-
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
-
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
-