Package edu.wisc.game.rest

## Class ParaSet

- java.lang.Object
- - java.util.AbstractMap<K,​V>
  - - java.util.HashMap<String,​Object>
    - - edu.wisc.game.rest.ParaSet

- All Implemented Interfaces:
    `Serializable`, `Cloneable`, `Map<String,​Object>`

      public class ParaSet
      extends HashMap<String,​Object>

  See Also:
    Serialized Form

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class | Description
    --- | --- | ---
    `static class` | `ParaSet.Incentive` | Various incentive schemes available to experiment designers.

    - ### Nested classes/interfaces inherited from class java.util.AbstractMap

      `AbstractMap.SimpleEntry<K extends Object,​V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object,​V extends Object>`

    - ### Nested classes/interfaces inherited from interface java.util.Map

      `Map.Entry<K extends Object,​V extends Object>`

  - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `Piece.Color[]` | `colors` |
    `ImageObject.Generator` | `imageGenerator` | Will be set as appropriate if the CSV file has an "images" column.
    `static ParaSet` | `legacy` | A dummy ParaSet object that contains legacy colors and shapes.
    `Piece.Shape[]` | `shapes` | Will be set as appropriate if specified in the CSV file "colors" column

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `ParaSet​(CsvData csv)` |
    `ParaSet​(File f)` |

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `checkColors​(ColorMap cm)` | Makes sure that this parameter set's color list (used for generating random boards) only contains valid colors (present in the color map)
    `void` | `checkImages()` |
    `void` | `checkIncentive()` | Checks whether the parameters related to incentive schemes are consistent (that is, you don't have a parameter from one scheme and another parameter from a different scheme).
    `void` | `checkShapes()` | Makes sure that this parameter set's shape list (used for generating random boards) only contains valid shapes (for which SVG files exist)
    `boolean` | `getBoolean​(String key, Boolean defVal)` |
    `double` | `getClearingThreshold()` |
    `String` | `getColors()` | For JSON
    `boolean` | `getCont()` |
    `double` | `getDouble​(String key)` |
    `double` | `getDouble​(String key, boolean optional, double defaultValue)` |
    `String` | `getImages()` |
    `ParaSet.Incentive` | `getIncentive()` | Returns the name of the incentive scheme in use in this para set, or null if none is apparenly is in effect.
    `int` | `getInt​(String key)` |
    `int` | `getInt​(String key, boolean optional, int defaultValue)` |
    `int` | `getMaxBoards()` |
    `double` | `getPickCost()` | The cost of a pick attempt, in terms of the cost of a move.
    `String` | `getRuleSetName()` |
    `String` | `getShapes()` |
    `String` | `getString​(String key, String defVal)` |
    `boolean` | `isFeedbackSwitchesFree()` | True if the player is not told which pieces are movable.
    `int` | `kantorLupyanReward​(double errors)` | Returns the reward for an episode with a given number of errors, computed by the Kantor-Lupyan formula.
    `double` | `kantorLupyanReward0​(double errors)` |
    `int[]` | `kantorLupyanRewardRange​(double errors)` |
    `static Piece.Color[]` | `parseColors​(String val)` |
    `static Piece.Shape[]` | `parseShapes​(String val)` | Parses a semicolon-separated list of shapes.
    `boolean` | `pickCostIsInt()` | Is the cost of a pick attempt an integer?
    `static ParaSet` | `textToParaSet​(String s)` | Processes ParaSet data that have been already read into string.
    `String` | `toString()` |

    - ### Methods inherited from class java.util.HashMap

      `clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values`

    - ### Methods inherited from class java.util.AbstractMap

      `equals, hashCode`

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

      `finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface java.util.Map

      `equals, hashCode`

- - ### Field Detail

    - #### shapes

          public Piece.Shape[] shapes

      Will be set as appropriate if specified in the CSV file "colors" column

    - #### colors

          public Piece.Color[] colors

    - #### imageGenerator

          public ImageObject.Generator imageGenerator

      Will be set as appropriate if the CSV file has an "images" column. The array elements are keys used for the image lookup. Otherwise, null

    - #### legacy

          public static final ParaSet legacy

      A dummy ParaSet object that contains legacy colors and shapes. This is used e.g. as a default context in the automatic rule generation.

  - ### Constructor Detail

    - #### ParaSet

          public ParaSet​(File f)
                  throws IOException,
                         IllegalInputException

      Throws:
        `IOException`
        `IllegalInputException`

    - #### ParaSet

          public ParaSet​(CsvData csv)
                  throws IOException

      Parameters:
        `csv` - One param per line
      Throws:
        `IOException`

  - ### Method Detail

    - #### getColors

          public String getColors()

      For JSON

    - #### getShapes

          public String getShapes()

    - #### getImages

          public String getImages()

    - #### parseShapes

          public static Piece.Shape[] parseShapes​(String val)
                                           throws IOException

      Parses a semicolon-separated list of shapes.
      Returns:
        An array of Shape values, or null if val is null or empty.
      Throws:
        `IOException` - On a parsing problem (invalid shape names)

    - #### parseColors

          public static Piece.Color[] parseColors​(String val)
                                           throws IOException

      Throws:
        `IOException`

    - #### textToParaSet

          public static ParaSet textToParaSet​(String s)
                                       throws IOException,
                                              IllegalInputException

      Processes ParaSet data that have been already read into string.
      Parameters:
        `s` - A multi-line string, which looks like the content of a traditional ParaSet CSV file. This can come over HTTP, for example.
      Throws:
        `IOException`
        `IllegalInputException`

    - #### getString

          public String getString​(String key,
                                  String defVal)

    - #### getInt

          public int getInt​(String key)

    - #### getDouble

          public double getDouble​(String key)

    - #### getBoolean

          public boolean getBoolean​(String key,
                                    Boolean defVal)

    - #### getDouble

          public double getDouble​(String key,
                                  boolean optional,
                                  double defaultValue)

      Parameters:
        `optional` - If true, this method will not throw an exception, and will return defaultValue, if the parameter is absent in the set
        `defaultValue` - Only used if optional==true

    - #### getInt

          public int getInt​(String key,
                            boolean optional,
                            int defaultValue)

    - #### getMaxBoards

          public int getMaxBoards()

    - #### getRuleSetName

          public String getRuleSetName()

    - #### getClearingThreshold

          public double getClearingThreshold()

    - #### getPickCost

          public double getPickCost()

      The cost of a pick attempt, in terms of the cost of a move. The default is 1.0. An early proposal called this param "pick_cost", but then I realized that Paul had planned for it all along, under a different name.

    - #### pickCostIsInt

          public boolean pickCostIsInt()

      Is the cost of a pick attempt an integer?

    - #### getCont

          public boolean getCont()

    - #### checkColors

          public void checkColors​(ColorMap cm)
                           throws IOException

      Makes sure that this parameter set's color list (used for generating random boards) only contains valid colors (present in the color map)
      Throws:
        `IOException`

    - #### checkShapes

          public void checkShapes()
                           throws IOException

      Makes sure that this parameter set's shape list (used for generating random boards) only contains valid shapes (for which SVG files exist)
      Throws:
        `IOException`

    - #### checkImages

          public void checkImages()
                           throws IOException

      Throws:
        `IOException`

    - #### isFeedbackSwitchesFree

          public boolean isFeedbackSwitchesFree()

      True if the player is not told which pieces are movable. (free = no objects are marked with X. Seeking to move an object is counted as some fraction of a move.)

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `AbstractMap<String,​Object>`

    - #### getIncentive

          public ParaSet.Incentive getIncentive()

      Returns the name of the incentive scheme in use in this para set, or null if none is apparenly is in effect. This is determined by the presence or absence of necessary parameters.

    - #### checkIncentive

          public void checkIncentive()
                              throws IllegalInputException

      Checks whether the parameters related to incentive schemes are consistent (that is, you don't have a parameter from one scheme and another parameter from a different scheme).
      Throws:
        `IllegalInputException`

    - #### kantorLupyanReward

          public int kantorLupyanReward​(double errors)

      Returns the reward for an episode with a given number of errors, computed by the Kantor-Lupyan formula. The Kantor-Lupyan formula for the reward computation is at https://www.desmos.com/calculator/9nyuxjy7ri . The actual min (asymptotic) is smin; the actual max (atd=0) is smin + (smax-smin)/(1+exp(-2*b)), which is a bit smaller than smax
      Parameters:
        `errors` - The number of errors the player has made in the episode. This can be a fractional number, if failed pick attempts are counted with a weight less than 1.0. The value Double.POSITIVE_INFINITY if allowed, in order to compute the lower bound of possible reward.

    - #### kantorLupyanReward0

          public double kantorLupyanReward0​(double errors)

    - #### kantorLupyanRewardRange

          public int[] kantorLupyanRewardRange​(double errors)

      Returns:
        (lowerBound, upperBound)