Class 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.
    • 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

      • setPlayer

        public void setPlayer​(PlayerInfo _player)
      • 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
      • 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
      • 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
      • 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).