Class RuleDirective
java.lang.Object
application.model.rules.ruleloader.Directive
application.model.rules.ruleloader.RuleDirective
public abstract class RuleDirective extends Directive
Represents a directive that represents the CA rule.
-
Field Summary
-
Constructor Summary
Constructors Constructor Description RuleDirective(java.lang.String content)
Constructs the directive with the provided content -
Method Summary
Modifier and Type Method Description abstract Coordinate[]
getNeighbourhood()
This method returns the neighbourhood of a given cellprotected Coordinate[]
getNeighbourhood(java.lang.String content)
Gets the neighbourhood of the rule given the line where the neighbourhood is defined.int
getNumStates()
Gets the number of states of the ruleprotected int[]
getStateWeights(java.lang.String content)
Gets the state weights of the rule given the line where the state weights are defined.protected Symmetry
getSymmetry(java.lang.String content)
Gets the symmetry from the line where the symmetry is definedTiling
getTiling()
Gets the tiling of the ruleprotected Tiling
getTiling(java.lang.String content)
Gets the tiling of the rule given the line where the tiling is definedprotected int[]
getWeights(java.lang.String content)
Gets the weights of the rule given the line where the weights are defined.abstract int
transitionFunc(int[] neighbours, int cellState)
This method represents the transition function of the ruleMethods inherited from class application.model.rules.ruleloader.Directive
clone, getDirectiveName, parseContent
-
Field Details
-
Constructor Details
-
RuleDirective
public RuleDirective(java.lang.String content)Constructs the directive with the provided content- Parameters:
content
- Content of the directive
-
-
Method Details
-
getTiling
Gets the tiling of the rule- Returns:
- Returns the tiling of the rule
-
getNumStates
public int getNumStates()Gets the number of states of the rule- Returns:
- Returns the number of states of the rule
-
getNeighbourhood
This method returns the neighbourhood of a given cell- Returns:
- A list of Coordinates that represent the neighbourhood
-
transitionFunc
public abstract int transitionFunc(int[] neighbours, int cellState)This method represents the transition function of the rule- 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
-
getNeighbourhood
Gets the neighbourhood of the rule given the line where the neighbourhood is defined. For example, "neighbourhood:Moore"- Parameters:
content
- The line where the neighbourhood is defined- Returns:
- Returns the neighbourhood of the rule
-
getWeights
protected int[] getWeights(java.lang.String content)Gets the weights of the rule given the line where the weights are defined. For example, "neighbourhood:[2 * (0, 1), ...]"- Parameters:
content
- The line where the weights is defined- Returns:
- Returns the weights of the rule
-
getSymmetry
Gets the symmetry from the line where the symmetry is defined- Parameters:
content
- The content of the line- Returns:
- Returns the symmetry obtained
-
getStateWeights
protected int[] getStateWeights(java.lang.String content)Gets the state weights of the rule given the line where the state weights are defined. For example, "state_weights:0,1,0,0..."- Parameters:
content
- The line where the state weights is defined- Returns:
- Returns the state weights of the rule
-
getTiling
Gets the tiling of the rule given the line where the tiling is defined- Parameters:
content
- The line where the tiling is defined- Returns:
- Returns the tiling of the rule
-