Class RuleDirective

java.lang.Object
application.model.rules.ruleloader.Directive
application.model.rules.ruleloader.RuleDirective
Direct Known Subclasses:
Ruletable, Ruletree, SQC

public abstract class RuleDirective
extends Directive
Represents a directive that represents the CA rule.
  • Field Summary

    Fields 
    Modifier and Type Field Description
    protected int numStates
    The number of states of the CA rule
    protected Tiling tiling
    The tiling of the CA rule

    Fields inherited from class application.model.rules.ruleloader.Directive

    directiveName
  • 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 cell
    protected 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 rule
    protected 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 defined
    Tiling getTiling()
    Gets the tiling of the rule
    protected Tiling getTiling​(java.lang.String content)
    Gets the tiling of the rule given the line where the tiling is defined
    protected 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 rule

    Methods inherited from class application.model.rules.ruleloader.Directive

    clone, getDirectiveName, parseContent

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • numStates

      protected int numStates
      The number of states of the CA rule
    • tiling

      protected Tiling tiling
      The tiling of the CA rule
  • 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

      public Tiling 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

      public abstract Coordinate[] 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 provided
      cellState - The current state of the cell
      Returns:
      The state of the cell in the next generation
    • getNeighbourhood

      protected Coordinate[] getNeighbourhood​(java.lang.String content)
      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

      protected Symmetry getSymmetry​(java.lang.String content)
      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

      protected Tiling getTiling​(java.lang.String content)
      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