Package edu.wisc.game.engine

## Class RuleSet

- java.lang.Object
- - edu.wisc.game.engine.RuleSet

-     public class RuleSet
      extends Object

  A RuleSet describes the rules of a game.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class | Description
    --- | --- | ---
    `static class` | `RuleSet.Atom` | Syntax:(counter,shape,color,position,bucketFunctions)
    `static class` | `RuleSet.BucketList` | A BucketList represents the information about the destination buckets given in the "buckets" field of an atom.
    `static class` | `RuleSet.BucketSelector` | The list of "legacy" variables that can be used in the bucket expression.
    `class` | `RuleSet.ReportedSrc` | This is used for pretty-printing in the GUI client.
    `static class` | `RuleSet.Row` | A row object represents the content of one line of the rule set description file, i.e.

  - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `Vector<String>` | `description` | An optional verbal description of the rule set, which may have been found in the comment lines on top of the rule set file.
    `String` | `display` | The display name, to show in the Android app, without giving the user too much of a hint.
    `TreeMap<String,​Order>` | `orders` | All orders
    `Vector<RuleSet.Row>` | `rows` | All rows of this rule set

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `RuleSet​(String ruleText)` |
    `RuleSet​(String[] rr)` | Creates a RuleSet based on the content of a rule set file.
    `RuleSet​(String[] rr, AutomaticRuleGenerator agen)` |
    `RuleSet​(String ruleText, AutomaticRuleGenerator agen)` |

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `File` | `getFile()` |
    `boolean` | `isPositionMask()` | This method returns true if this RuleSet is purely a fixed position selector, i.e.
    `HashSet<String>` | `listAllBucketVars()` | The list of variables mentioned in the bucket expressions in this row
    `HashSet<Piece.Color>` | `listAllColors()` | Lists all colors used in this rule set.
    `TreeMap<String,​TreeSet<String>>` | `listAllPropValues()` | Lists all properties, and all property values, used in this rule set.
    `HashSet<Piece.Shape>` | `listAllShapes()` | Lists all shapes used in this rule set.
    `static void` | `main​(String[] argv)` |
    `RuleSet.ReportedSrc` | `reportSrc()` |
    `String` | `toSrc()` | Format as the source code of the rules set
    `String` | `toString()` |

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### description

          public Vector<String> description

      An optional verbal description of the rule set, which may have been found in the comment lines on top of the rule set file.

    - #### display

          public String display

      The display name, to show in the Android app, without giving the user too much of a hint. (As per PK, 2023-01-24)

    - #### orders

          public TreeMap<String,​Order> orders

      All orders

    - #### rows

          public Vector<RuleSet.Row> rows

      All rows of this rule set

  - ### Constructor Detail

    - #### RuleSet

          public RuleSet​(String ruleText)
                  throws RuleParseException

      Throws:
        `RuleParseException`

    - #### RuleSet

          public RuleSet​(String ruleText,
                         AutomaticRuleGenerator agen)
                  throws RuleParseException

      Throws:
        `RuleParseException`

    - #### RuleSet

          public RuleSet​(String[] rr)
                  throws RuleParseException

      Creates a RuleSet based on the content of a rule set file. The file may contain some (optional) custom order definition lines, followed by one or more rule lines.
      Parameters:
        `rr` - The lines from the rule set file
      Throws:
        `RuleParseException`

    - #### RuleSet

          public RuleSet​(String[] rr,
                         AutomaticRuleGenerator agen)
                  throws RuleParseException

      Throws:
        `RuleParseException`

  - ### Method Detail

    - #### getFile

          public File getFile()

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### toSrc

          public String toSrc()

      Format as the source code of the rules set

    - #### reportSrc

          public RuleSet.ReportedSrc reportSrc()

    - #### listAllShapes

          public HashSet<Piece.Shape> listAllShapes()

      Lists all shapes used in this rule set.

    - #### listAllColors

          public HashSet<Piece.Color> listAllColors()

      Lists all colors used in this rule set.

    - #### listAllPropValues

          public TreeMap<String,​TreeSet<String>> listAllPropValues()

      Lists all properties, and all property values, used in this rule set. This is primarily used for correctness checking during the experiment plan validation.

    - #### listAllBucketVars

          public HashSet<String> listAllBucketVars()

      The list of variables mentioned in the bucket expressions in this row

    - #### isPositionMask

          public boolean isPositionMask()

      This method returns true if this RuleSet is purely a fixed position selector, i.e. it simply tells that certain positions are allowed. FIXME: this is not precise, but is just a heuristic, to help the random board generator when conditions are imposed

    - #### main

          public static void main​(String[] argv)
                           throws IOException,
                                  RuleParseException

      Throws:
        `IOException`
        `RuleParseException`