Ejemplo n.º 1
0
    def __init__(self, parent=None):
        super(GuiConfigure, self).__init__(parent)

        layout = QtGui.QVBoxLayout(self)

        self._widpayoffs = WCombo(
            label=trans_GP(u"Display summary (with payoffs)?"),
            items=(trans_GP(u"No"), trans_GP(u"Yes")), parent=self)
        layout.addWidget(self._widpayoffs)

        button = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok)
        button.accepted.connect(self.accept)
        layout.addWidget(button)

        self.setWindowTitle(trans_GP(u"Configure"))
        self.adjustSize()
        self.setFixedSize(self.size())
Ejemplo n.º 2
0
    def __init__(self, parent=None):
        super(GuiConfigure, self).__init__(parent)

        layout = QtGui.QVBoxLayout(self)

        self._widpayoffs = WCombo(
            label=trans_GP(u"Display summary (with payoffs)?"),
            items=(trans_GP(u"No"), trans_GP(u"Yes")),
            parent=self)
        layout.addWidget(self._widpayoffs)

        button = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok)
        button.accepted.connect(self.accept)
        layout.addWidget(button)

        self.setWindowTitle(trans_GP(u"Configure"))
        self.adjustSize()
        self.setFixedSize(self.size())
Ejemplo n.º 3
0
    def __init__(self, defered, automatique, parent, periode, historique):
        super(GuiDecision, self).__init__(parent)

        self._defered = defered
        self._automatique = automatique

        layout = QtGui.QVBoxLayout(self)

        self._widexplication = WExplication(
            text=texts_GP.get_text_explanation(), size=(500, 70), parent=self)
        layout.addWidget(self._widexplication)

        self._widdecision = WSpinbox(label=trans_GP(
            u"Choose the amount you want to invest in the "
            u"risky option"),
                                     minimum=pms.DECISION_MIN,
                                     maximum=pms.DECISION_MAX,
                                     interval=pms.DECISION_STEP,
                                     parent=self,
                                     automatique=self._automatique)
        layout.addWidget(self._widdecision)

        # bouton box
        buttons = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok,
                                         QtCore.Qt.Horizontal, self)
        buttons.accepted.connect(self._accept)
        layout.addWidget(buttons)

        if self._automatique:
            self._timer_automatique = QtCore.QTimer()
            self._timer_automatique.timeout.connect(
                buttons.button(QtGui.QDialogButtonBox.Ok).click)
            self._timer_automatique.start(7000)

        # title and size
        self.setWindowTitle(le2mtrans(u"Decision"))
        self.adjustSize()
        self.setFixedSize(self.size())
Ejemplo n.º 4
0
    def __init__(self, defered, automatique, parent, periode, historique):
        super(GuiDecision, self).__init__(parent)

        self._defered = defered
        self._automatique = automatique

        layout = QtGui.QVBoxLayout(self)

        self._widexplication = WExplication(
            text=texts_GP.get_text_explanation(), size=(500, 70), parent=self)
        layout.addWidget(self._widexplication)

        self._widdecision = WSpinbox(
            label=trans_GP(u"Choose the amount you want to invest in the "
                           u"risky option"),
            minimum=pms.DECISION_MIN, maximum=pms.DECISION_MAX,
            interval=pms.DECISION_STEP, parent=self,
            automatique=self._automatique)
        layout.addWidget(self._widdecision)

        # bouton box
        buttons = QtGui.QDialogButtonBox(
            QtGui.QDialogButtonBox.Ok, QtCore.Qt.Horizontal, self)
        buttons.accepted.connect(self._accept)
        layout.addWidget(buttons)

        if self._automatique:
            self._timer_automatique = QtCore.QTimer()
            self._timer_automatique.timeout.connect(
                buttons.button(QtGui.QDialogButtonBox.Ok).click)
            self._timer_automatique.start(7000)

        # title and size
        self.setWindowTitle(le2mtrans(u"Decision"))
        self.adjustSize()
        self.setFixedSize(self.size())
Ejemplo n.º 5
0
    def _demarrer(self):
        confirmation = self._le2mserv.gestionnaire_graphique.\
            question(trans_GP(u"Start Gneezy Potter?"))
        if not confirmation:
            return

        # init part ============================================================
        yield (self._le2mserv.gestionnaire_experience.init_part(
            "GneezyPotter", "PartieGP", "RemoteGP", pms))
        self._tous = self._le2mserv.gestionnaire_joueurs.get_players(
            "GneezyPotter")

        # set parameters to remotes
        yield (self._le2mserv.gestionnaire_experience.run_func(
            self._tous, "configure"))

        # start of 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, le2mtrans(u"Period {}").format(period)])
            self._le2mserv.gestionnaire_graphique.infoclt(
                [None, le2mtrans(u"Period {}").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"Decision", self._tous, "display_decision"))

            self._le2mserv.gestionnaire_graphique.infoserv(
                trans_GP(u"Random draws"))
            for p in self._tous:
                tirage = random.random()
                if tirage <= pms.PROBA:
                    p.currentperiod.GP_randomdraw = PILE
                else:
                    p.currentperiod.GP_randomdraw = FACE
                self._le2mserv.gestionnaire_graphique.infoserv(
                    "{}: {:.3f} => {}".format(
                        p.joueur, tirage, u"pile"
                        if p.currentperiod.GP_randomdraw == PILE else u"face"))

            # period payoff
            self._le2mserv.gestionnaire_experience.compute_periodpayoffs(
                "GneezyPotter")

            # summary
            if pms.DISPLAY_SUMMARY:
                yield (self._le2mserv.gestionnaire_experience.run_step(
                    u"Summary", self._tous, "display_summary"))

        # end of part ==========================================================
        # stats
        data = pd.DataFrame(
            [p.currentperiod.todict(p.joueur) for p in self._tous])
        data = data.groupby(data.joueur).mean()["GP_decision"]
        self._le2mserv.gestionnaire_graphique.infoserv(
            trans_GP(u"Av. amount invested"))
        self._le2mserv.gestionnaire_graphique.infoserv(data.to_string())
        self._fig, graph = plt.subplots(figsize=(6, 6))
        data.plot(kind="bar", ax=graph)
        graph.set_xticklabels([str(i)[-3:-1] for i in data.index])
        graph.set_ylim(0, pms.DOTATION)
        graph.set_xlabel("Players")
        graph.set_ylabel("Amount invested")
        graph.set_title("Amount invested in the risky option")

        yield (self._le2mserv.gestionnaire_experience.finalize_part(
            "GneezyPotter"))
Ejemplo n.º 6
0
    def _demarrer(self):
        confirmation = self._le2mserv.gestionnaire_graphique.\
            question(trans_GP(u"Start Gneezy Potter?"))
        if not confirmation:
            return

        # init part ============================================================
        yield (self._le2mserv.gestionnaire_experience.init_part(
            "GneezyPotter", "PartieGP", "RemoteGP", pms))
        self._tous = self._le2mserv.gestionnaire_joueurs.get_players(
            "GneezyPotter")

        # set parameters to remotes
        yield (self._le2mserv.gestionnaire_experience.run_func(
            self._tous, "configure"))

        # start of 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, le2mtrans(u"Period {}").format(period)])
            self._le2mserv.gestionnaire_graphique.infoclt(
                [None, le2mtrans(u"Period {}").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"Decision", self._tous, "display_decision"))

            self._le2mserv.gestionnaire_graphique.infoserv(trans_GP(u"Random draws"))
            for p in self._tous:
                tirage = random.random()
                if tirage <= pms.PROBA:
                    p.currentperiod.GP_randomdraw = PILE
                else:
                    p.currentperiod.GP_randomdraw = FACE
                self._le2mserv.gestionnaire_graphique.infoserv(
                    "{}: {:.3f} => {}".format(
                        p.joueur, tirage,
                        u"pile" if p.currentperiod.GP_randomdraw == PILE else
                        u"face"))

            # period payoff
            self._le2mserv.gestionnaire_experience.compute_periodpayoffs(
                "GneezyPotter")

            # summary
            if pms.DISPLAY_SUMMARY:
                yield(self._le2mserv.gestionnaire_experience.run_step(
                    u"Summary", self._tous, "display_summary"))

        # end of part ==========================================================
        # stats
        data = pd.DataFrame(
            [p.currentperiod.todict(p.joueur) for p in self._tous])
        data = data.groupby(data.joueur).mean()["GP_decision"]
        self._le2mserv.gestionnaire_graphique.infoserv(
            trans_GP(u"Av. amount invested"))
        self._le2mserv.gestionnaire_graphique.infoserv(data.to_string())
        self._fig, graph = plt.subplots(figsize=(6, 6))
        data.plot(kind="bar", ax=graph)
        graph.set_xticklabels([str(i)[-3:-1] for i in data.index])
        graph.set_ylim(0, pms.DOTATION)
        graph.set_xlabel("Players")
        graph.set_ylabel("Amount invested")
        graph.set_title("Amount invested in the risky option")

        yield (self._le2mserv.gestionnaire_experience.finalize_part(
            "GneezyPotter"))