Beispiel #1
0
    def run(self, tries):
        """Calculates the win % for each preflop hand, returns the mapping"""
        cards = c.full_deck()
        self.wins = {}
        self.tries = tries

        for count, two_cards in enumerate(itertools.combinations(cards, 2)):
            t1 = time.clock()
            hand = c.Hand(two_cards[0], two_cards[1])
            hand_string = hand.simple()
            if self.wins.get(hand_string) is not None:
                print "Skipping {}. Already computed its simple representation ({})" \
                  .format(hand, hand_string)
                continue
            simulator = HandSimulator(hand)
            percent_pots_won = simulator.simulate(tries)

            self.wins[hand_string] = percent_pots_won

            print ' {hand} ({s}) won {percent}% in {tries} tries in {t} seconds' \
                .format(hand=hand, s=hand_string,
                        tries=tries,
                        percent=percent_pots_won,
                        t=(time.clock() - t1))

            # 52 choose 2 == 1326
            # We go through everything even though we only calculate 169 hands
            percent_done = MathUtils.percentage(count, 1326)
            print ' Finished hand {c} ({p:.2f}%)' \
                .format(c=count, p=percent_done)
            print '-' * 10
Beispiel #2
0
    def run(self, tries):
        """Calculates the win % for each preflop hand, returns the mapping"""
        cards = c.full_deck()
        self.wins = {}
        self.tries = tries
        count = 0

        for two_cards in itertools.combinations(cards, 2):
            t1 = time.clock()
            hand = c.Hand(two_cards[0], two_cards[1])
            simulator = HandSimulator(hand)
            percent_pots_won = simulator.simulate(tries)

            self.wins[repr(hand)] = percent_pots_won

            print ' {hand} won {percent}% in {tries} tries in {t} seconds' \
                .format(hand=hand,
                        tries=tries,
                        percent=percent_pots_won,
                        t=(time.clock() - t1))

            count += 1
            # 52 choose 2 == 1326
            percent_done = MathUtils.percentage(count, 1326)
            print ' Finished hand {c} ({p}%)' \
                .format(c=count, p=round(percent_done))
            print '-'*10
Beispiel #3
0
    def run(self, tries):
        """Calculates the win % for each preflop hand, returns the mapping"""
        cards = c.full_deck()
        self.wins = {}
        self.tries = tries

        for count, two_cards in enumerate(itertools.combinations(cards, 2)):
            t1 = time.clock()
            hand = c.Hand(two_cards[0], two_cards[1])
            hand_string = hand.simple()
            if self.wins.get(hand_string) is not None:
                print "Skipping {}. Already computed its simple representation ({})" \
                  .format(hand, hand_string)
                continue
            simulator = HandSimulator(hand)
            percent_pots_won = simulator.simulate(tries)

            self.wins[hand_string] = percent_pots_won

            print ' {hand} ({s}) won {percent}% in {tries} tries in {t} seconds' \
                .format(hand=hand, s=hand_string,
                        tries=tries,
                        percent=percent_pots_won,
                        t=(time.clock() - t1))

            # 52 choose 2 == 1326
            # We go through everything even though we only calculate 169 hands
            percent_done = MathUtils.percentage(count, 1326)
            print ' Finished hand {c} ({p:.2f}%)' \
                .format(c=count, p=percent_done)
            print '-'*10
Beispiel #4
0
 def __repr__(self):
     hands = len(self.pots)
     avg_pot = sum(self.pots) / hands
     stats = ["hands={h}, avg_pot={p:.2f}" \
              .format(h=hands, p=avg_pot)]
     for i, p in enumerate(self.HOLDEM_PHASES):
         phase_count = self.phases.get(i, 0)
         if phase_count == 0:
             continue
         phase_percent = MathUtils.percentage(phase_count, hands)
         stats.append("{}=({:.2f}%)".format(p, phase_percent))
     return ", ".join(stats)