Package edu.wisc.game.sql

## Class ReplayedEpisode

- java.lang.Object
- - edu.wisc.game.sql.Episode
  - - edu.wisc.game.sql.ReplayedEpisode

-     public class ReplayedEpisode
      extends Episode

  Built on top of an Episode object, a ReplayedEpisode is created during the analysis of transcripts, in order to recreate the episode's events step by step. This is primarily needed so that we can compute the p0(D) value for each move of the episode.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class | Description
    --- | --- | ---
    `static class` | `ReplayedEpisode.RandomPlayer` | The possible random player models.

    - ### Nested classes/interfaces inherited from class edu.wisc.game.sql.Episode

      `Episode.CODE, Episode.Display, Episode.FINISH_CODE, Episode.Move, Episode.OutputMode, Episode.Pick`

  - ### Field Summary

    - ### Fields inherited from class edu.wisc.game.sql.Episode

      `episodeId, NBU, random, ruleLine, ruleLineNo, sdf, sdf2, version`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `ReplayedEpisode​(String _episodeId, ParaSet _para, Game game, ReplayedEpisode.RandomPlayer _randomPlayerModel)` | Creates an Episode in order to replay an old recorded Game (with a known rule set and a known initial board).

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `int` | `accept​(Episode.Pick pick)` | In addition to the normal "accept" stuff, either erases or augments the player's knowledge of the current board's properties.
    `double` | `computeP0​(Episode.Pick nextMove, int code)` | Computes the probability of success for a random pick or random move made by a frugal player.
    `static void` | `main​(String[] argv)` | A unit test, which can be run without relying on SQL, just with files in the transcript and board directories.
    `boolean` | `weShowAllMovables()` | We tell the player where all movable pieces are, unless the para set mandates "free" mode.

    - ### Methods inherited from class edu.wisc.game.sql.Episode

      `displayJson, doMove, doMove2, doPick, doPick2, findJ, getAttemptCnt, getCurrentBoard, getCurrentBoard, getEpisodeId, getIsJMoveable, getLastMove, getLastMovePos, getNPiecesStart, getStartTime, getTranscript, getValues, getVersion, graphicDisplay, graphicDisplay, graphicDisplayAscii, isCompleted, mkDisplay0, onBoard, playGame, randomWord, report, setEpisodeId, setNPiecesStart, setStartTime`

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

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

- - ### Constructor Detail

    - #### ReplayedEpisode

          public ReplayedEpisode​(String _episodeId,
                                 ParaSet _para,
                                 Game game,
                                 ReplayedEpisode.RandomPlayer _randomPlayerModel)

      Creates an Episode in order to replay an old recorded Game (with a known rule set and a known initial board).

  - ### Method Detail

    - #### weShowAllMovables

          public boolean weShowAllMovables()

      We tell the player where all movable pieces are, unless the para set mandates "free" mode.
      Overrides:
        `weShowAllMovables` in class `Episode`

    - #### computeP0

          public double computeP0​(Episode.Pick nextMove,
                                  int code)

      Computes the probability of success for a random pick or random move made by a frugal player. A call to this method should precede a call to accept(). As of 2021-09-18, the approach is that "P0 for a pick" is only used for successful picks (i.e. when there is incontrovertible evidence that the player wanted to do a pick). For failed picks, we use the "P0 for a move", since it's believed that the player most likely intended to attempt a move, but the GUI converts a move attempt on an immovable piece to a failed pick.
      Parameters:
        `nextMove` - The pick/move attempt the value of p0 before which (for which) we want to compute. This pick or move has been read from the transcript, and contains the success code, which we can use to interpret what the random player may have wanted here. The nextMove.code field is not set yet, because it will only be set during an actual replay (the Episode.accept() call).
        `code` - The historical acceptance code for this attempt, as read from the transcript

    - #### accept

          public int accept​(Episode.Pick pick)

      In addition to the normal "accept" stuff, either erases or augments the player's knowledge of the current board's properties. (Depending on whether the board has changed or not).
      Overrides:
        `accept` in class `Episode`

    - #### main

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

      A unit test, which can be run without relying on SQL, just with files in the transcript and board directories.

      Usage: java ReplayedEpisode exp playerId

      //FIXME: if the data set contains any adve 2PG, this thing won't know what the adversary's (Player 1's) playerId was, because it's not recorded in the CSV files. (It's only on the SQL database).

      Throws:
        `IOException`
        `IllegalInputException`
        `RuleParseException`