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 classEpisodeInfo.ExtendedDisplayProvides 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>globalAllEpisodesTable with all episodes recently played on this server.
-
Constructor Summary
Constructors Constructor Description EpisodeInfo()Dummy episode, used for sending error mesages onlyEpisodeInfo(Game game, ParaSet _para)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcache()EpisodeInfo.ExtendedDisplaydoMove(String moverPlayerId, int y, int x, int by, int bx, int _attemptCnt)The main method invoked on a /move web API call.EpisodeInfo.ExtendedDisplaydoMove2(String moverPlayerId, int pieceId, int bucketId, int _attemptCnt)EpisodeInfo.ExtendedDisplaydoPick(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.ExtendedDisplaydoPick2(String moverPlayerId, int pieceId, int _attemptCnt)EpisodeInfo.ExtendedDisplaydummyDisplay(int _code, String _errmsg)BoardgetCurrentBoard()Shows the current board (including dropped pieces, which are labeled as such)intgetFinishCode()Overrides Episode.FinishCode, taking special care of the walk away/abandoned situation.intgetFirstMover()StringgetGuess()StringgetGuess1()intgetGuess1Confidence()booleangetGuess1Saved()Has the guess from player 1 (in 2PG) been saved?intgetGuessConfidence()booleangetGuessSaved()Has the guess from the player (in 1PG) or from player 0 (in 2PG) been saved?booleangetGuessSavedBy(int mover)doublegetLastR()doublegetLastR1()For Player 1, in adversarial games onlyintgetLastStretch()intgetLastStretch1()For Player 1, in adversarial games onlyPlayerInfogetPlayer()intgetRewardMain()intgetRewardMain1()intgetSeriesNo()intgetXFactor()intgetXFactor1()booleanisBonus()Episode.PicklastMove()static EpisodeInfolocateEpisode(String eid)EpisodeInfo.ExtendedDisplaymkDisplay(String playerId)Builds a Dsplay object to be sent out over the web UI on a /display callStringreport()Concise report, handy for debuggingStringreportKey()The key that can be printed next to reports to help understand themvoidsaveChatToFile(File f, int mover, String text)#mover,seriesNo,episodeNo,timestamp,textvoidsaveGuessToFile(File f, String moverPlayerId, String guessText, int confidence)Records the player-provided "guess" to a CSV filevoidsetAllGuessData(int mover, String text, int confidence)Sets all guess-related fields of this episode for one of the partnersvoidsetBonus(boolean _bonus)voidsetFirstMover(int _firstMover)voidsetGuess(String _guess)Sets the guess value, truncating it if necessaryvoidsetGuess1(String _guess1)Sets the guess value, truncating it if necessaryvoidsetGuess1Confidence(int _guess1Confidence)voidsetGuess1Saved(boolean _guess1Saved)voidsetGuessConfidence(int _guessConfidence)voidsetGuessSaved(boolean _guessSaved)voidsetLastR(double x)voidsetLastR1(double x)voidsetLastStretch(int x)voidsetLastStretch1(int x)voidsetPlayer(PlayerInfo _player)voidsetRewardMain(int x)voidsetRewardMain(int j, int x)voidsetRewardMain1(int x)voidsetSeriesNo(int _seriesNo)voidsetXFactor(int x)voidsetXFactor1(int x)booleanweShowAllMovables()Our GUI tells the player where all movable pieces are, unless the para set mandates "free" mode.intwhoMadeLastMove()Which player made the last recorded move of this episode? (Needed for 2PG only)intwhoMustMakeNextMove()Called at the beginning of /move call, before testing for acceptance.Episode.MovexgetLastProposed()ParaSetxgetPara()-
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
-
-
-
-
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
-
-
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:
weShowAllMovablesin classEpisode
-
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
-
getCurrentBoard
public Board getCurrentBoard()
Shows the current board (including dropped pieces, which are labeled as such)- Overrides:
getCurrentBoardin classEpisode
-
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()
-
-