Class Ruletree

java.lang.Object
All Implemented Interfaces:
Exportable

public class Ruletree
extends RuleDirective
implements Exportable
Implements Golly ruletrees with additional features such as arbitary neighbourhoods. See http://golly.sourceforge.net/Help/formats.html for more information.
  • Constructor Details

    • Ruletree

      public Ruletree​(java.lang.String content)
      Constructs a ruletree with the provided content
      Parameters:
      content - Content to use to construct the ruletree
  • Method Details

    • parseContent

      public void parseContent​(java.lang.String content)
      Parses the content of the ruletree
      Specified by:
      parseContent in class Directive
      Parameters:
      content - The content of the ruletree
    • 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
    • export

      public java.lang.String export()
      Description copied from interface: Exportable
      Exports the directive to Golly / Lifelib
      Specified by:
      export in interface Exportable
      Returns:
      The exported directive to be parsed by Golly or Lifelib