Class Ruletable

java.lang.Object

public class Ruletable
extends RuleDirective
Implements Golly ruletables with addition features such as unbounded rules and arbitrary neighbourhoods. See https://github.com/GollyGang/ruletablerepository/wiki. TODO (Nutshell syntax)
  • Field Summary

    Fields 
    Modifier and Type Field Description
    static Variable ANY
    The predefined LIVE, DEAD and ANY variables
    static Variable DEAD
    The predefined LIVE, DEAD and ANY variables
    static Variable LIVE
    The predefined LIVE, DEAD and ANY variables

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

    numStates, tiling

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

    directiveName
  • Constructor Summary

    Constructors 
    Constructor Description
    Ruletable​(java.lang.String content)
    Constructs the ruletable with the provided content
  • Method Summary

    Modifier and Type Method Description
    void addINTTransitions​(INTTransitions transitions1, INTTransitions transitions2, java.lang.String input, java.lang.String output, java.lang.String var0, java.lang.String var1, java.lang.String var2)
    Adds isotropic non-totalistic transitions to the ruletable
    void addINTTransitions​(INTTransitions transitions, java.lang.String input, java.lang.String output, java.lang.String var0, java.lang.String var1)
    Adds isotropic non-totalistic transitions to the ruletable
    void addOTTransition​(int transition, java.lang.String input, java.lang.String output, java.lang.String var0, java.lang.String var1)
    Adds an outer totalistic transition to the ruletable
    void addOTTransition​(java.util.List<java.lang.Integer> transition, java.lang.String input, java.lang.String output, java.util.List<java.lang.String> vars)
    Adds an outer totalistic transition with multiple states to the ruletable
    void addOTTransitions​(java.lang.Iterable<java.lang.Integer> transitions, java.lang.String input, java.lang.String output, java.lang.String var0, java.lang.String var1)
    Adds outer totalistic transitions to the ruletable
    void addTransition​(java.lang.String transitionLine)
    Adds a transition to the ruletable
    void addVariable​(Variable variable)
    Adds a variable to the ruletable
    java.lang.Object clone()
    Deep copies the directive
    Coordinate[] getNeighbourhood()
    This method returns the neighbourhood of a given cell
    java.util.ArrayList<Transition> getTransitions()
    Gets all the transitions of the ruletable
    java.util.Map<java.lang.String,​Variable> getVariables()
    Gets all the variables of the ruletable
    boolean isPermute()
    Is permute symmetry used?
    void parseContent​(java.lang.String content)
    Parses the content of the ruletable
    void setNeighbourhood​(Coordinate[] neighbourhood)
    Sets the neighbourhood of the ruletable
    void setNumStates​(int numStates)
    Sets the number of states of the ruletable
    void setPermute()
    Enables permute symmetry
    void setSymmetry​(Symmetry symmetry)
    Sets the symmetry of the ruletable
    void setWeights​(int[] weights)
    Sets the weights of the ruletable
    int transitionFunc​(int[] neighbours, int cellState)
    This method represents the transition function of the rule
    void updateNeighbourhoodSum()
    Updates the neighbourhood sum

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

    getNeighbourhood, getNumStates, getStateWeights, getSymmetry, getTiling, getTiling, getWeights

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

    getDirectiveName

    Methods inherited from class java.lang.Object

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

    • LIVE

      public static Variable LIVE
      The predefined LIVE, DEAD and ANY variables
    • DEAD

      public static Variable DEAD
      The predefined LIVE, DEAD and ANY variables
    • ANY

      public static Variable ANY
      The predefined LIVE, DEAD and ANY variables
  • Constructor Details

    • Ruletable

      public Ruletable​(java.lang.String content)
      Constructs the ruletable with the provided content
      Parameters:
      content - Content of the ruletable
  • Method Details

    • parseContent

      public void parseContent​(java.lang.String content) throws java.lang.IllegalArgumentException
      Parses the content of the ruletable
      Specified by:
      parseContent in class Directive
      Parameters:
      content - The content of the ruletable
      Throws:
      java.lang.IllegalArgumentException - Thrown when the ruletable inputted is invalid
    • getNeighbourhood

      public Coordinate[] getNeighbourhood()
      Description copied from class: RuleDirective
      This method returns the neighbourhood of a given cell
      Specified by:
      getNeighbourhood in class RuleDirective
      Returns:
      A list of Coordinates that represent the neighbourhood
    • transitionFunc

      public int transitionFunc​(int[] neighbours, int cellState)
      Description copied from class: RuleDirective
      This method represents the transition function of the rule
      Specified by:
      transitionFunc in class RuleDirective
      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
    • clone

      public java.lang.Object clone()
      Description copied from class: Directive
      Deep copies the directive
      Specified by:
      clone in class Directive
      Returns:
      Return a deepcopy of the directive
    • addVariable

      public void addVariable​(Variable variable)
      Adds a variable to the ruletable
      Parameters:
      variable - The variable to be added
    • addTransition

      public void addTransition​(java.lang.String transitionLine)
      Adds a transition to the ruletable
      Parameters:
      transitionLine - The string representing the transition
    • addOTTransition

      public void addOTTransition​(int transition, java.lang.String input, java.lang.String output, java.lang.String var0, java.lang.String var1)
      Adds an outer totalistic transition to the ruletable
      Parameters:
      transition - The transition to add to the ruletable
      input - The input state / variable
      output - The output state / variable
      var0 - The state / variable that represents state 0
      var1 - The state / variable that represents state 1
    • addOTTransition

      public void addOTTransition​(java.util.List<java.lang.Integer> transition, java.lang.String input, java.lang.String output, java.util.List<java.lang.String> vars)
      Adds an outer totalistic transition with multiple states to the ruletable
      Parameters:
      transition - The transition to add to the ruletable
      input - The input state / variable
      output - The output state / variable
      vars - The variables that represent each state
    • addOTTransitions

      public void addOTTransitions​(java.lang.Iterable<java.lang.Integer> transitions, java.lang.String input, java.lang.String output, java.lang.String var0, java.lang.String var1)
      Adds outer totalistic transitions to the ruletable
      Parameters:
      transitions - The transitions to add to the ruletable
      input - The input state / variable
      output - The output state / variable
      var0 - The state / variable that represents state 0
      var1 - The state / variable that represents state 1
    • addINTTransitions

      public void addINTTransitions​(INTTransitions transitions, java.lang.String input, java.lang.String output, java.lang.String var0, java.lang.String var1)
      Adds isotropic non-totalistic transitions to the ruletable
      Parameters:
      transitions - The transitions to add to the ruletable
      input - The input state / variable
      output - The output state / variable
      var0 - The state / variable that represents state 0
      var1 - The state / variable that represents state 1
    • addINTTransitions

      public void addINTTransitions​(INTTransitions transitions1, INTTransitions transitions2, java.lang.String input, java.lang.String output, java.lang.String var0, java.lang.String var1, java.lang.String var2)
      Adds isotropic non-totalistic transitions to the ruletable
      Parameters:
      transitions1 - The 1st transition to add to the ruletable
      transitions2 - The 2nd transition to add to the ruletable
      input - The input state / variable
      output - The output state / variable
      var0 - The state / variable that represents state 0
      var1 - The state / variable that represents state 1
      var2 - The state / variable that represents state 2
    • setPermute

      public void setPermute()
      Enables permute symmetry
    • isPermute

      public boolean isPermute()
      Is permute symmetry used?
      Returns:
      True if permute symmetry is used, false otherwise
    • setSymmetry

      public void setSymmetry​(Symmetry symmetry)
      Sets the symmetry of the ruletable
      Parameters:
      symmetry - The symmetry of the ruletable
    • setNumStates

      public void setNumStates​(int numStates)
      Sets the number of states of the ruletable
      Parameters:
      numStates - The number of states of the ruletable
    • setWeights

      public void setWeights​(int[] weights)
      Sets the weights of the ruletable
      Parameters:
      weights - The weights of the ruletable
    • setNeighbourhood

      public void setNeighbourhood​(Coordinate[] neighbourhood)
      Sets the neighbourhood of the ruletable
      Parameters:
      neighbourhood - The neighbourhood of the ruletable
    • updateNeighbourhoodSum

      public void updateNeighbourhoodSum()
      Updates the neighbourhood sum
    • getVariables

      public java.util.Map<java.lang.String,​Variable> getVariables()
      Gets all the variables of the ruletable
      Returns:
      Returns all the variables of the ruletable
    • getTransitions

      public java.util.ArrayList<Transition> getTransitions()
      Gets all the transitions of the ruletable
      Returns:
      Returns the transitions of the ruletable