예제 #1
0
파일: brain.py 프로젝트: Junglebobo/poker
    def __do_turn(self, timeLeft_ms):
        """Callback for when the brain has to make a decision"""
        if not self.data.hand:
            self.bot.log("No hand, killing ourselves. Data={d}"
                         .format(d=self.data))
            self.bot.fold()
            return

        hand = self.data.hand
        pot_odds = self.pot_odds()
        equity = 0

        if not self.data.table_cards:
            equity = self.preflop_equity[repr(hand)]
        else:
            simulator = HandSimulator(hand, self.data.table_cards)
            best_hand, score = simulator.best_hand()
            self.bot.log("best 5: {b} score: {s}"
                         .format(b=str(best_hand), s=score))
            equity = simulator.simulate(self.iterations)

        self.bot.log("{h}, equity: {e}%, pot odds: {p}%"
                     .format(h=hand, e=equity, p=pot_odds))

        self.pick_action(equity, pot_odds)
예제 #2
0
    def __do_turn(self, time_left_ms):
        """Callback for when the brain has to make a decision"""
        if not self.data.hand:
            self.bot.log("No hand, killing ourselves. Data={d}"
                         .format(d=self.data))
            self.bot.fold()
            return

        hand = self.data.hand
        stack = self.our_stack()
        to_call = self.to_call(silent=False)
        pot_odds = self.pot_odds()
        equity = 0
        self.update_fear(to_call)
        preflop_fear = self.data.preflop_fear
        hand_fear = self.data.hand_fear

        # preflop, no big raises. safe to use our precalculated win %
        if not self.data.table_cards and preflop_fear == -1:
            equity = self.preflop_equity[hand.simple()]
            source = "preflop"
        else:
            simulator = HandSimulator(hand, self.data.table_cards,
                                      self.preflop_equity)
            best_hand, score = simulator.best_hand()
            equity = self.__run_simulator(simulator, time_left_ms,
                                          preflop_fear, hand_fear)
            source = "sim"

        self.bot.log(" hand: {h}, table: {t}"
                     .format(h=hand, t=[str(t) for t in self.data.table_cards]))
        if self.data.table_cards:
            self.bot.log(" best 5: {b} score: {s}"
                         .format(b=[str(c) for c in best_hand], s=str(score)))
        self.bot.log(" win: {e:.2f}% ({s}), pot odds: {p:.2f}%, stack={m}"
                     .format(e=equity, s=source, p=pot_odds, m=stack))
        self.bot.log(" pre-fear={pf}, hand-fear=({hf})"
                     .format(pf=preflop_fear, hf=hand_fear))

        self.pick_action(equity, to_call, pot_odds)