def get_text_summary(period_content): txt = trans_DP(u"You chose {} and the other player chose {}.").format( pms.get_option(period_content.get("DP_decision")), pms.get_option(period_content.get("DP_decisionother"))) txt += u" " + trans_DP(u"Your payoff is {}.").format( get_pluriel(period_content.get("DP_periodpayoff"), pms.MONNAIE)) return txt
def compute_periodpayoff(self): """ Compute the payoff for the period :return: """ logger.debug(u"{} Period Payoff".format(self.joueur)) self.currentperiod.DP_periodpayoff = 0 if self.currentperiod.DP_decision == pms.get_option("X"): if self.currentperiod.DP_decisionother == pms.get_option("X"): self.currentperiod.DP_periodpayoff = pms.XX else: self.currentperiod.DP_periodpayoff = pms.XY else: if self.currentperiod.DP_decisionother == pms.get_option("Y"): self.currentperiod.DP_periodpayoff = pms.YX else: self.currentperiod.DP_periodpayoff = pms.YY # cumulative payoff since the first period if self.currentperiod.DP_period < 2: self.currentperiod.DP_cumulativepayoff = \ self.currentperiod.DP_periodpayoff else: previousperiod = self.periods[ self.currentperiod.DP_period - 1] self.currentperiod.DP_cumulativepayoff = \ previousperiod.DP_cumulativepayoff + \ self.currentperiod.DP_periodpayoff # we store the period in the self.periodes dictionnary self.periods[self.currentperiod.DP_period] = self.currentperiod logger.debug(u"{} Period Payoff {}".format( self.joueur, self.currentperiod.DP_periodpayoff))
def display_decision(self): """ Display the decision screen on the remote Get back the decision :return: """ logger.debug(u"{} Decision".format(self.joueur)) debut = datetime.now() self.currentperiod.DP_decision = \ yield(self.remote.callRemote("display_decision")) self.currentperiod.DP_decisiontime = \ (datetime.now() - debut).seconds self.joueur.info(u"{}".format( pms.get_option(self.currentperiod.DP_decision))) self.joueur.remove_waitmode()
def remote_display_summary(self, period_content): logger.info(u"{} Summary".format(self._le2mclt.uid)) line = [] for k in self._histo_vars: if k == "DP_decision" or k == "DP_decisionother": line.append(pms.get_option(period_content.get(k))) else: line.append(period_content.get(k)) self.histo.append(line) if self._le2mclt.simulation: return 1 else: defered = defer.Deferred() ecran_recap = GuiRecapitulatif( defered, self._le2mclt.automatique, self._le2mclt.screen, self.currentperiod, self.histo, texts_DP.get_text_summary(period_content)) ecran_recap.show() return defered
def _demarrer(self): """ Start the part :return: """ # check conditions ===================================================== if self._le2mserv.gestionnaire_joueurs.nombre_joueurs % \ pms.TAILLE_GROUPES: self._le2mserv.gestionnaire_graphique.display_error( le2mtrans(u"The number of players is not compatible with " u"the group size")) return confirmation = self._le2mserv.gestionnaire_graphique.\ question(u"Démarrer prisonnersDilemma?") if not confirmation: return # init part ============================================================ yield (self._le2mserv.gestionnaire_experience.init_part( "prisonnersDilemma", "PartieDP", "RemoteDP", pms)) self._tous = self._le2mserv.gestionnaire_joueurs.get_players( 'prisonnersDilemma') self._le2mserv.gestionnaire_groupes.former_groupes( self._le2mserv.gestionnaire_joueurs.get_players(), pms.TAILLE_GROUPES, forcer_nouveaux=True) # set parameters on remotes yield (self._le2mserv.gestionnaire_experience.run_func( self._tous, "configure")) # Start part =========================================================== for period in xrange(1 if pms.NOMBRE_PERIODES else 0, pms.NOMBRE_PERIODES + 1): if self._le2mserv.gestionnaire_experience.stop_repetitions: break # init period self._le2mserv.gestionnaire_graphique.infoserv( [None, u"Période {}".format(period)]) self._le2mserv.gestionnaire_graphique.infoclt( [None, u"Période {}".format(period)], fg="white", bg="gray") yield (self._le2mserv.gestionnaire_experience.run_func( self._tous, "newperiod", period)) # decision yield (self._le2mserv.gestionnaire_experience.run_step( u"Décision", self._tous, "display_decision")) for g, m in self._le2mserv.gestionnaire_groupes.\ get_groupes("prisonnersDilemma").iteritems(): txtchoix = u"" m[0].currentperiod.DP_decisionother = \ m[1].currentperiod.DP_decision txtchoix += pms.get_option(m[0].currentperiod.DP_decision) m[1].currentperiod.DP_decisionother = \ m[0].currentperiod.DP_decision txtchoix += pms.get_option(m[1].currentperiod.DP_decision) self._le2mserv.gestionnaire_graphique.infoserv( u"G{}: {}".format(g.split("_")[2], txtchoix)) # period payoff self._le2mserv.gestionnaire_experience.compute_periodpayoffs( "prisonnersDilemma") # summary yield (self._le2mserv.gestionnaire_experience.run_step( u"Récapitulatif", self._tous, "display_summary")) # End of part ========================================================== yield (self._le2mserv.gestionnaire_experience.finalize_part( "prisonnersDilemma"))
def _demarrer(self): """ Start the part :return: """ # check conditions ===================================================== if self._le2mserv.gestionnaire_joueurs.nombre_joueurs % \ pms.TAILLE_GROUPES: self._le2mserv.gestionnaire_graphique.display_error( le2mtrans(u"The number of players is not compatible with " u"the group size")) return confirmation = self._le2mserv.gestionnaire_graphique.\ question(u"Démarrer prisonnersDilemma?") if not confirmation: return # init part ============================================================ yield (self._le2mserv.gestionnaire_experience.init_part( "prisonnersDilemma", "PartieDP", "RemoteDP", pms)) self._tous = self._le2mserv.gestionnaire_joueurs.get_players( 'prisonnersDilemma') self._le2mserv.gestionnaire_groupes.former_groupes( self._le2mserv.gestionnaire_joueurs.get_players(), pms.TAILLE_GROUPES, forcer_nouveaux=True) # set parameters on remotes yield (self._le2mserv.gestionnaire_experience.run_func( self._tous, "configure")) # Start part =========================================================== for period in xrange(1 if pms.NOMBRE_PERIODES else 0, pms.NOMBRE_PERIODES + 1): if self._le2mserv.gestionnaire_experience.stop_repetitions: break # init period self._le2mserv.gestionnaire_graphique.infoserv( [None, u"Période {}".format(period)]) self._le2mserv.gestionnaire_graphique.infoclt( [None, u"Période {}".format(period)], fg="white", bg="gray") yield (self._le2mserv.gestionnaire_experience.run_func( self._tous, "newperiod", period)) # decision yield(self._le2mserv.gestionnaire_experience.run_step( u"Décision", self._tous, "display_decision")) for g, m in self._le2mserv.gestionnaire_groupes.\ get_groupes("prisonnersDilemma").iteritems(): txtchoix = u"" m[0].currentperiod.DP_decisionother = \ m[1].currentperiod.DP_decision txtchoix += pms.get_option(m[0].currentperiod.DP_decision) m[1].currentperiod.DP_decisionother = \ m[0].currentperiod.DP_decision txtchoix += pms.get_option(m[1].currentperiod.DP_decision) self._le2mserv.gestionnaire_graphique.infoserv( u"G{}: {}".format(g.split("_")[2], txtchoix)) # period payoff self._le2mserv.gestionnaire_experience.compute_periodpayoffs( "prisonnersDilemma") # summary yield(self._le2mserv.gestionnaire_experience.run_step( u"Récapitulatif", self._tous, "display_summary")) # End of part ========================================================== yield (self._le2mserv.gestionnaire_experience.finalize_part( "prisonnersDilemma"))