Package edu.wisc.game.sql

## Class EpisodeInfo

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

-     @Entity
      public class EpisodeInfo
      extends Episode

  An EpisodeInfo instance extends an Episode, containing additional information related to it being played as part of an experiment. That includes support for creating an Episode based on a parameter set, and for managing earned reward amount.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class | Description
    --- | --- | ---
    `class` | `EpisodeInfo.ExtendedDisplay` | Provides some extra information related to the episode's context within the experiment.

    - ### 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
    Modifier and Type | Field | Description
    --- | --- | ---
    `static HashMap<String,​EpisodeInfo>` | `globalAllEpisodes` | Table with all episodes recently played on this server.

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

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

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `EpisodeInfo()` | Dummy episode, used for sending error mesages only
    `EpisodeInfo​(Game game, ParaSet _para)` |

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `cache()` |
    `EpisodeInfo.ExtendedDisplay` | `doMove​(String moverPlayerId, int y, int x, int by, int bx, int _attemptCnt)` | The main method invoked on a /move web API call.
    `EpisodeInfo.ExtendedDisplay` | `doMove2​(String moverPlayerId, int pieceId, int bucketId, int _attemptCnt)` |
    `EpisodeInfo.ExtendedDisplay` | `doPick​(String moverPlayerId, int y, int x, int _attemptCnt)` | Like /doMove, but without a destination (because the game piece was not movable, or because the player just dropped in on the board)
    `EpisodeInfo.ExtendedDisplay` | `doPick2​(String moverPlayerId, int pieceId, int _attemptCnt)` |
    `EpisodeInfo.ExtendedDisplay` | `dummyDisplay​(int _code, String _errmsg)` |
    `Board` | `getCurrentBoard()` | Shows the current board (including dropped pieces, which are labeled as such)
    `int` | `getFinishCode()` | Overrides Episode.FinishCode, taking special care of the walk away/abandoned situation.
    `int` | `getFirstMover()` |
    `String` | `getGuess()` |
    `String` | `getGuess1()` |
    `int` | `getGuess1Confidence()` |
    `boolean` | `getGuess1Saved()` | Has the guess from player 1 (in 2PG) been saved?
    `int` | `getGuessConfidence()` |
    `boolean` | `getGuessSaved()` | Has the guess from the player (in 1PG) or from player 0 (in 2PG) been saved?
    `boolean` | `getGuessSavedBy​(int mover)` |
    `double` | `getLastR()` |
    `double` | `getLastR1()` | For Player 1, in adversarial games only
    `int` | `getLastStretch()` |
    `int` | `getLastStretch1()` | For Player 1, in adversarial games only
    `PlayerInfo` | `getPlayer()` |
    `int` | `getRewardMain()` |
    `int` | `getRewardMain1()` |
    `int` | `getSeriesNo()` |
    `int` | `getXFactor()` |
    `int` | `getXFactor1()` |
    `boolean` | `isBonus()` |
    `Episode.Pick` | `lastMove()` |
    `static EpisodeInfo` | `locateEpisode​(String eid)` |
    `EpisodeInfo.ExtendedDisplay` | `mkDisplay​(String playerId)` | Builds a Dsplay object to be sent out over the web UI on a /display call
    `String` | `report()` | Concise report, handy for debugging
    `String` | `reportKey()` | The key that can be printed next to reports to help understand them
    `void` | `saveChatToFile​(File f, int mover, String text)` | #mover,seriesNo,episodeNo,timestamp,text
    `void` | `saveGuessToFile​(File f, String moverPlayerId, String guessText, int confidence)` | Records the player-provided "guess" to a CSV file
    `void` | `setAllGuessData​(int mover, String text, int confidence)` | Sets all guess-related fields of this episode for one of the partners
    `void` | `setBonus​(boolean _bonus)` |
    `void` | `setFirstMover​(int _firstMover)` |
    `void` | `setGuess​(String _guess)` | Sets the guess value, truncating it if necessary
    `void` | `setGuess1​(String _guess1)` | Sets the guess value, truncating it if necessary
    `void` | `setGuess1Confidence​(int _guess1Confidence)` |
    `void` | `setGuess1Saved​(boolean _guess1Saved)` |
    `void` | `setGuessConfidence​(int _guessConfidence)` |
    `void` | `setGuessSaved​(boolean _guessSaved)` |
    `void` | `setLastR​(double x)` |
    `void` | `setLastR1​(double x)` |
    `void` | `setLastStretch​(int x)` |
    `void` | `setLastStretch1​(int x)` |
    `void` | `setPlayer​(PlayerInfo _player)` |
    `void` | `setRewardMain​(int x)` |
    `void` | `setRewardMain​(int j, int x)` |
    `void` | `setRewardMain1​(int x)` |
    `void` | `setSeriesNo​(int _seriesNo)` |
    `void` | `setXFactor​(int x)` |
    `void` | `setXFactor1​(int x)` |
    `boolean` | `weShowAllMovables()` | Our GUI tells the player where all movable pieces are, unless the para set mandates "free" mode.
    `int` | `whoMadeLastMove()` | Which player made the last recorded move of this episode? (Needed for 2PG only)
    `int` | `whoMustMakeNextMove()` | Called at the beginning of /move call, before testing for acceptance.
    `Episode.Move` | `xgetLastProposed()` |
    `ParaSet` | `xgetPara()` |

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

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

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

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

- - ### Field Detail

    - #### globalAllEpisodes

          public static HashMap<String,​EpisodeInfo> globalAllEpisodes

      Table with all episodes recently played on this server. It is kept to enable quick lookup of episode by id. Episode objects are put into this table upon creation. FIXME: should purge the table occasionally, to save memory

  - ### Constructor Detail

    - #### EpisodeInfo

          public EpisodeInfo()

      Dummy episode, used for sending error mesages only

    - #### EpisodeInfo

          public EpisodeInfo​(Game game,
                             ParaSet _para)

  - ### Method Detail

    - #### getPlayer

          public PlayerInfo getPlayer()

    - #### setPlayer

          public void setPlayer​(PlayerInfo _player)

    - #### locateEpisode

          public static EpisodeInfo locateEpisode​(String eid)

    - #### cache

          public void cache()

    - #### isBonus

          public boolean isBonus()

    - #### setBonus

          public void setBonus​(boolean _bonus)

    - #### getRewardMain

          public int getRewardMain()

    - #### setRewardMain

          public void setRewardMain​(int x)

    - #### getRewardMain1

          public int getRewardMain1()

    - #### setRewardMain1

          public void setRewardMain1​(int x)

    - #### setRewardMain

          public void setRewardMain​(int j,
                                    int x)

    - #### getSeriesNo

          public int getSeriesNo()

    - #### setSeriesNo

          public void setSeriesNo​(int _seriesNo)

    - #### getGuessSaved

          public boolean getGuessSaved()

      Has the guess from the player (in 1PG) or from player 0 (in 2PG) been saved?

    - #### setGuessSaved

          public void setGuessSaved​(boolean _guessSaved)

    - #### getGuess1Saved

          public boolean getGuess1Saved()

      Has the guess from player 1 (in 2PG) been saved?

    - #### setGuess1Saved

          public void setGuess1Saved​(boolean _guess1Saved)

    - #### getGuessSavedBy

          public boolean getGuessSavedBy​(int mover)

      Returns:
        the "guessSaved" fields for a particular player

    - #### getGuess

          public String getGuess()

    - #### setGuess

          public void setGuess​(String _guess)

      Sets the guess value, truncating it if necessary

    - #### getGuess1

          public String getGuess1()

    - #### setGuess1

          public void setGuess1​(String _guess1)

      Sets the guess value, truncating it if necessary

    - #### getGuessConfidence

          public int getGuessConfidence()

    - #### setGuessConfidence

          public void setGuessConfidence​(int _guessConfidence)

    - #### getGuess1Confidence

          public int getGuess1Confidence()

    - #### setGuess1Confidence

          public void setGuess1Confidence​(int _guess1Confidence)

    - #### getLastStretch

          public int getLastStretch()

    - #### setLastStretch

          public void setLastStretch​(int x)

    - #### getLastStretch1

          public int getLastStretch1()

      For Player 1, in adversarial games only

    - #### setLastStretch1

          public void setLastStretch1​(int x)

    - #### getLastR

          public double getLastR()

    - #### setLastR

          public void setLastR​(double x)

    - #### getLastR1

          public double getLastR1()

      For Player 1, in adversarial games only

    - #### setLastR1

          public void setLastR1​(double x)

    - #### getXFactor

          public int getXFactor()

    - #### setXFactor

          public void setXFactor​(int x)

    - #### getXFactor1

          public int getXFactor1()

    - #### setXFactor1

          public void setXFactor1​(int x)

    - #### getFirstMover

          public int getFirstMover()

    - #### setFirstMover

          public void setFirstMover​(int _firstMover)

    - #### xgetPara

          public ParaSet xgetPara()

    - #### weShowAllMovables

          public boolean weShowAllMovables()

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

    - #### doMove

          public EpisodeInfo.ExtendedDisplay doMove​(String moverPlayerId,
                                                    int y,
                                                    int x,
                                                    int by,
                                                    int bx,
                                                    int _attemptCnt)
                                             throws IOException

      The main method invoked on a /move web API call. Calls Episode.doMove, and then does various adjustments related to this episode's role in the experiment plan. If the player has failed to complete a bonus episode on time, this is the place that sets the "lost" flag.
      Parameters:
        `playerId` - null in single-player games; playerId in 2PG
        `_attemptCnt` - According to the client, this is how many /move or /pick calls it has made before this call; so this is how long the transcript of this episode should be.
      Throws:
        `IOException`

    - #### doMove2

          public EpisodeInfo.ExtendedDisplay doMove2​(String moverPlayerId,
                                                     int pieceId,
                                                     int bucketId,
                                                     int _attemptCnt)
                                              throws IOException

      Throws:
        `IOException`

    - #### doPick

          public EpisodeInfo.ExtendedDisplay doPick​(String moverPlayerId,
                                                    int y,
                                                    int x,
                                                    int _attemptCnt)
                                             throws IOException

      Like /doMove, but without a destination (because the game piece was not movable, or because the player just dropped in on the board)
      Throws:
        `IOException`

    - #### doPick2

          public EpisodeInfo.ExtendedDisplay doPick2​(String moverPlayerId,
                                                     int pieceId,
                                                     int _attemptCnt)
                                              throws IOException

      Throws:
        `IOException`

    - #### reportKey

          public String reportKey()

      The key that can be printed next to reports to help understand them

    - #### report

          public String report()

      Concise report, handy for debugging
      Overrides:
        `report` in class `Episode`

    - #### getCurrentBoard

          public Board getCurrentBoard()

      Shows the current board (including dropped pieces, which are labeled as such)
      Overrides:
        `getCurrentBoard` in class `Episode`

    - #### mkDisplay

          public EpisodeInfo.ExtendedDisplay mkDisplay​(String playerId)

      Builds a Dsplay object to be sent out over the web UI on a /display call
      Parameters:
        `playerId` - This can be null in 1PG, but in 2PG it must identify the player to whom we are to show the display

    - #### dummyDisplay

          public EpisodeInfo.ExtendedDisplay dummyDisplay​(int _code,
                                                          String _errmsg)

    - #### saveGuessToFile

          public void saveGuessToFile​(File f,
                                      String moverPlayerId,
                                      String guessText,
                                      int confidence)

      Records the player-provided "guess" to a CSV file
      Parameters:
        `moverPlayerId` - The playerId of the actual player who made the guess. In a 2PG, this is not necessarily the same player who owns the EpisodeInfo instance, because each partner's guess goes into his own file.

    - #### saveChatToFile

          public void saveChatToFile​(File f,
                                     int mover,
                                     String text)

                  #mover,seriesNo,episodeNo,timestamp,text

    - #### whoMadeLastMove

          public int whoMadeLastMove()

      Which player made the last recorded move of this episode? (Needed for 2PG only)
      Returns:
        normally, 0 or 1; if there were no moves, -1

    - #### lastMove

          public Episode.Pick lastMove()

      Returns:
        The last move of the episode, or null if the episode was empty (no moves, because the para set allowed the player to give up without playing)

    - #### whoMustMakeNextMove

          public int whoMustMakeNextMove()

      Called at the beginning of /move call, before testing for acceptance. Also can be called at the end of the /move or /display call (after acceptance and recording in the transcript), to decide who'll make the following move.

    - #### setAllGuessData

          public void setAllGuessData​(int mover,
                                      String text,
                                      int confidence)

      Sets all guess-related fields of this episode for one of the partners

    - #### getFinishCode

          public int getFinishCode()

      Overrides Episode.FinishCode, taking special care of the walk away/abandoned situation. (The episode entry is stored only once, shared by the two players; but the finish code should be returned differently to the two players).

    - #### xgetLastProposed

          public Episode.Move xgetLastProposed()