Package edu.wisc.game.sql
Class PlayerInfo
java.lang.Object
edu.wisc.game.sql.PlayerInfo
@Entity public class PlayerInfo extends Object
A PlayerInfo object represent information about a player (what trial list he's in, what episodes he's done etc) stored in the SQL database. It is identiied by a playerId (a string). A humans playing the Rule Game may create just one PlayerInfo object (a single playerId), if he comes from the Mechanical Turk, or goes directly to the GUI Client URL; or he can create many such objects (each one with a particular experiment plan), if he starts many games from the Repeat User Launch page, or from the Android app. In the latter case, all such PlayerInfo objects are linked to a single User object.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPlayerInfo.ActionWhat type of action takes the player to a particular destination?static classPlayerInfo.TransitionWhere can we go from here?classPlayerInfo.TransitionMap -
Constructor Summary
Constructors Constructor Description PlayerInfo() -
Method Summary
Modifier and Type Method Description voidactivateBonus(javax.persistence.EntityManager em)Switches this player from the main subseries to the bonus subseries, and saves the information about this fact in the SQL server.voidaddEpisode(EpisodeInfo c)booleanalreadyFinished()Returns true if the current series number is set beyond the possible range, which indicates that it has gone through the last possible increment (and, therefore, the completion code has been set as well).booleancanActivateBonus()intcountBonusEpisodes(int k)How many bonus episodes (complete or not) are currently in series No.EpisodeInfoepisodeToDo()Returns the currently unfinished last episode to be resumed, or a new episode (in the current series or the next series, as the case may be), or null if this player has finished with all series.Vector<EpisodeInfo>getAllEpisodes()StringgetCompletionCode()The completion code, a string that the player can report as a proof of his completion of the experiment plan.intgetCurrentSeriesNo()DategetDate()StringgetExperimentPlan()The experiment plan historically was just a directory name, e.g.ParaSetgetFirstPara()Gives a link to the first ParaSet.longgetId()ParaSetgetPara(EpisodeInfo epi)Gives a link to the ParaSet associated with a given episodeStringgetPlayerId()A human-readable string ID for this player.intgetSuperseriesSize(int k)How many episodes are in the current super-series?intgetTotalRewardEarned()StringgetTrialListId()For traditional (static) and "P:"-type dynamic experiment plans, this is the name of the actual trial list file in the appropriate experiment plan directory (without the ".csv" extension).UsergetUser()voidgiveUp(int seriesNo)"Gives up" he current series, i.e.doublegoodnessScore()Compute the "goodness score" of this player, intended to measure how good this player has been, to be used during the postgame experience to decide if the demographics page should contain an invitation to participate in additional research (only offered to good players).voidinitSeries(TrialList trialList)This is usesd when a player is first registered and a PlayerInfo object is first created.EpisodeInfomostRecentEpisode()Retrieves the most recent episode, which may be completed or incomplete.voidremoveEpisode(EpisodeInfo c)Stringreport()Generates a concise report on this player's history, handy for debugging.voidrestoreTransientFields()This method should be called after restoring the object from the SQL database, in order to re-create some of the necessary non-persistent structures.voidsaveMe()Saves this object (and the associated Episode objects, via cascading) data in the SQL database.intseriesSize(int k)How many episodes are currently in series No.voidsetAllEpisodes(Vector<EpisodeInfo> _allEpisodes)voidsetCompletionCode(String _completionCode)voidsetDate(Date _date)voidsetExperimentPlan(String _experimentPlan)voidsetPlayerId(String _playerId)voidsetTotalRewardEarned(int _totalRewardEarned)voidsetTrialListId(String _trialListId)voidsetUser(User _user)StringtoString()
-
Constructor Details
-
PlayerInfo
public PlayerInfo()
-
-
Method Details
-
getId
public long getId() -
getUser
-
setUser
-
getPlayerId
A human-readable string ID for this player. A mandatory non-null value, which we strive to keep unique (by the PlayerResponse code). -
setPlayerId
-
getExperimentPlan
The experiment plan historically was just a directory name, e.g. "pilot06". Starting from ver. 3.004, dynamic experiment plans are also supported, in the form P:plan:modifer or R:ruleSet:modifier. -
setExperimentPlan
-
getTrialListId
For traditional (static) and "P:"-type dynamic experiment plans, this is the name of the actual trial list file in the appropriate experiment plan directory (without the ".csv" extension). For "R:"-type dynamic experiment plans (which do not involve any trial list files) this field, rather tautologically, contains the rule set name. -
setTrialListId
-
getDate
-
setDate
-
addEpisode
-
removeEpisode
-
getAllEpisodes
-
setAllEpisodes
-
toString
-
alreadyFinished
public boolean alreadyFinished()Returns true if the current series number is set beyond the possible range, which indicates that it has gone through the last possible increment (and, therefore, the completion code has been set as well). -
getSuperseriesSize
public int getSuperseriesSize(int k)How many episodes are in the current super-series?- Parameters:
k- (internal) series number. It is assumed that this is the last (internal) series in its super-series.
-
canActivateBonus
public boolean canActivateBonus()- Returns:
- true if an "Activate Bonus" button can be displayed, i.e. the player is eligible to start bonus episodes, but has not done that yet
-
activateBonus
public void activateBonus(javax.persistence.EntityManager em)Switches this player from the main subseries to the bonus subseries, and saves the information about this fact in the SQL server.- Parameters:
em- The active EM to use. (We have this because this method is called from a method that has an EM anyway, and this object is NOT detached.)
-
giveUp
"Gives up" he current series, i.e. immediately switches the player to the next series (if there is one).- Throws:
IOException
-
seriesSize
public int seriesSize(int k)How many episodes are currently in series No. k? -
countBonusEpisodes
public int countBonusEpisodes(int k)How many bonus episodes (complete or not) are currently in series No. k? -
getCurrentSeriesNo
public int getCurrentSeriesNo() -
initSeries
public void initSeries(TrialList trialList) throws IOException, IllegalInputException, ReflectiveOperationException, RuleParseExceptionThis is usesd when a player is first registered and a PlayerInfo object is first created. -
restoreTransientFields
public void restoreTransientFields() throws IOException, IllegalInputException, ReflectiveOperationException, RuleParseExceptionThis method should be called after restoring the object from the SQL database, in order to re-create some of the necessary non-persistent structures. Typically, this may be needed if player resumes his activity after the Game Server has been restarted. In particular, we restore the "series" structure, reloading paramter sets from the disk files and and putting episodes in their series arrays.We also review the episodes, and "give up" all incomplete ones, because they don't have their transcripts and rules loaded, and cannot be continued. This may happen only rarely, when an episode had been persisted before beeing completed (thru cascading from the player being persisted), and then the server was restarted.
-
mostRecentEpisode
Retrieves the most recent episode, which may be completed or incomplete. -
episodeToDo
Returns the currently unfinished last episode to be resumed, or a new episode (in the current series or the next series, as the case may be), or null if this player has finished with all series. This is used by the /GameService2/newEpisode web API call.- Throws:
IOExceptionRuleParseException
-
getPara
Gives a link to the ParaSet associated with a given episode -
getFirstPara
Gives a link to the first ParaSet. This is used for things that are determined by the first ParaSet, e.g. the pregame experience.- Returns:
- the ParaSet for the first series, or null if none exists.
-
getCompletionCode
The completion code, a string that the player can report as a proof of his completion of the experiment plan. It is set when the current series number is incremented beyond the last parameter set number. -
setCompletionCode
-
getTotalRewardEarned
public int getTotalRewardEarned() -
setTotalRewardEarned
public void setTotalRewardEarned(int _totalRewardEarned) -
report
Generates a concise report on this player's history, handy for debugging. It gives summaries of all episodes done (or in progress) by this player, broken down by series. -
saveMe
public void saveMe()Saves this object (and the associated Episode objects, via cascading) data in the SQL database. The assumption is that this object is detached, so we call a method which will create a new EM and merge this object to the new persistence context. -
goodnessScore
public double goodnessScore()Compute the "goodness score" of this player, intended to measure how good this player has been, to be used during the postgame experience to decide if the demographics page should contain an invitation to participate in additional research (only offered to good players). At present (ver 6.029), this score is only computed in a non-trivial way in games with the incentive plan Incentive.DOUBLING.- Returns:
- For players in games with the incentive plan Incentive.DOUBLING, the value of the score, in the range [0..1], is simply the fraction of all rule sets so far that the player has mastered (received X4). For players in other incentive plans, 0 is returned.
-