Package application.model.rules.hrot
Class BaseHROT
java.lang.Object
application.model.rules.Rule
application.model.rules.RuleFamily
application.model.rules.hrot.BaseHROT
- All Implemented Interfaces:
java.lang.Cloneable
- Direct Known Subclasses:
DeficientHROT
,HROT
,HROTBSFKL
,HROTExtendedGenerations
,HROTGenerations
,HROTRegeneratingGenerations
,IntegerHROT
,MultistateCyclicHROT
public abstract class BaseHROT extends RuleFamily
The base class of all HROT rules
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.String
hrotTransitions
The regex for HROT birth / survival / whatever transitionsprotected int
maxNeighbourhoodCount
The maximum possible neighbourhood count.protected Coordinate[]
neighbourhood
Neighbourhood of the HROT ruleprotected static java.lang.String
neighbourhoodRegex
The regex for the HROT neighbourhood specifierprotected int[]
weights
Weights of the HROT ruleFields inherited from class application.model.rules.Rule
alternatingPeriod, background, boundedGrid, numStates, readingOrder, tiling
-
Constructor Summary
Constructors Constructor Description BaseHROT()
-
Method Summary
Modifier and Type Method Description java.lang.String[]
generateComments()
Generates comments that will be placed in the RLE.Coordinate[]
getNeighbourhood(int generation)
This method returns the neighbourhood of a given cell at a certain generationprotected java.lang.String
getNeighbourhoodSpecifier(java.lang.String rulestring)
Gets the neighbourhood specifier from the rulestringjava.util.Map<java.lang.String,java.lang.String>
getRuleInfo()
Gets information about the ruleint[]
getWeights()
Gets the weights of the HROT rulevoid
loadComments(java.lang.String[] comments)
Loads the weights stored in the comments generated by generateCommentsprotected void
loadNeighbourhood(int range, java.lang.String specifier)
Loads the neighbourhood from the N...void
setNeighbourhood(Coordinate[] neighbourhood)
Sets the neighbourhood of the HROT rulevoid
setWeights(int[] weights)
Sets the weights of the HROT ruleMethods inherited from class application.model.rules.RuleFamily
canonise, clone, equals, fromRulestring, getDescription, getName, getNeighbourList, getRegex, 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, transitionFunc
-
Field Details
-
weights
protected int[] weightsWeights of the HROT rule -
neighbourhood
Neighbourhood of the HROT rule -
hrotTransitions
protected static final java.lang.String hrotTransitionsThe regex for HROT birth / survival / whatever transitions- See Also:
- Constant Field Values
-
neighbourhoodRegex
protected static final java.lang.String neighbourhoodRegexThe regex for the HROT neighbourhood specifier -
maxNeighbourhoodCount
protected int maxNeighbourhoodCountThe maximum possible neighbourhood count. Used for B0 and min, max rule generation.
-
-
Constructor Details
-
BaseHROT
public BaseHROT()
-
-
Method Details
-
generateComments
public java.lang.String[] generateComments()Generates comments that will be placed in the RLE. These comments represent weights. They are only generated if the neighbourhood specifier is N@ with no additional hex digits- Overrides:
generateComments
in classRuleFamily
- 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 weights stored in the comments generated by generateComments- Overrides:
loadComments
in classRuleFamily
- Parameters:
comments
- The comments from the RLE (all starting with #R)
-
getNeighbourhoodSpecifier
protected java.lang.String getNeighbourhoodSpecifier(java.lang.String rulestring)Gets the neighbourhood specifier from the rulestring- Parameters:
rulestring
- The rulestring of the rule- Returns:
- Returns the neighbourhood specifier of the rulestring
-
loadNeighbourhood
protected void loadNeighbourhood(int range, java.lang.String specifier)Loads the neighbourhood from the N... specifier- Parameters:
range
- The range of the neighbourhoodspecifier
- The specifier for the neighbourhood
-
setNeighbourhood
Sets the neighbourhood of the HROT rule- Parameters:
neighbourhood
- Neighbourhood of the HROT rule
-
setWeights
public void setWeights(int[] weights)Sets the weights of the HROT rule- Parameters:
weights
- Weights of the HROT rule
-
getNeighbourhood
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
-
getWeights
public int[] getWeights()Gets the weights of the HROT rule- Returns:
- Weights of the HROT rule
-
getRuleInfo
public java.util.Map<java.lang.String,java.lang.String> getRuleInfo()Description copied from class:RuleFamily
Gets information about the rule- Overrides:
getRuleInfo
in classRuleFamily
- Returns:
- Returns information about the rule in a map
-