Example #1
0
    def getWinner(self, roundIsOver):
        # if only one person hasn't folded
        if len(self.alivePlayers) == 1:
            print 'Winner: ' + self.alivePlayers[0].name
            #insere os jogadores da espera
            self.insertWaitingPlayers()
            return self.alivePlayers[0]

        # else if all betting rounds are over (round 4)
        if self.bettingRound == 4:
            # rank the hands of all alive players (players that haven't folded)
            eval = SevenEval()
            ranks = []
            for p in self.alivePlayers:
                hand  = list(self.communityCards)
                for c in p.hand:
                    hand.append(c)
                ranks.append(eval.getRankOfSeven(*hand))

            # winner has highest ranked hand
            maxValue = max(ranks)
            indexes = [i for i, v in enumerate(ranks) if v == maxValue]
            print 'Winner is ' + self.alivePlayers[indexes[0]].name + '!'
            #caso todas as rodadas se esgotaram e o vencedor definido, insere os novos jogadores
            self.insertWaitingPlayers()
            return self.alivePlayers[indexes[0]]
        return None
Example #2
0
        deck = range(52)
        random.shuffle(deck)
        hand = []
        board = []
        for j in range(2):
            hand.append(deck.pop(0))
        for j in range(m):
            board.append(deck.pop(0))

        hands.append(hand)
        boards.append(board)

    return boards, hands


s = SevenEval()

N = 10000
cumtime = 0.0
boards, hands = setup(N, 5)
for i in range(len(boards)):
    start = time.time()
    s.getRankOfSeven(*(boards[i] + hands[i]))
    cumtime += (time.time() - start)

avg = float(cumtime / N)
print("7 card evaluation:")
print("[*] SpecialK: Average time per evaluation: %f" % avg)
print("[*] SpecialK: Evaluations per second = %f" % (1.0 / avg))

####
Example #3
0
'''
Created on 11 mai 2012

@author: Askylh Snake
'''
from SevenEval import SevenEval

Heval=SevenEval()

print(Heval.getRankOfSeven(0, 2, 3, 4, 3, 5, 6))
Example #4
0
        deck = range(52)
        random.shuffle(deck)
        hand = []
        board = []
        for j in range(2):
            hand.append(deck.pop(0))
        for j in range(m):
            board.append(deck.pop(0))

        hands.append(hand)
        boards.append(board)

    return boards, hands

s = SevenEval()

N = 10000
cumtime = 0.0
boards, hands = setup(N, 5)
for i in range(len(boards)):
    start = time.time()
    s.getRankOfSeven(*(boards[i] + hands[i]))
    cumtime += (time.time() - start)

avg = float(cumtime / N)
print "7 card evaluation:"
print "[*] SpecialK: Average time per evaluation: %f" % avg
print "[*] SpecialK: Evaluations per second = %f" % (1.0 / avg)

####