コード例 #1
0
    def resolve_game(self, players):
        # print('Community cards: ', end='')
        # Card.print_pretty_cards(self.community)
        if len(players) == 1:
            players[0].refund(sum(self._side_pots))
            # print('Player', players[0].playerID, 'wins the pot (',sum(self._side_pots),')')
            self._totalpot = 0
        else:
            # compute hand ranks
            print("Board: ", Card.print_pretty_cards(self.community))
            for player in players:
                player.handrank = self._evaluator.evaluate(
                    player.hand, self.community)
                print("Player: {}".format(player.playerID),
                      Card.print_pretty_cards(player.hand))
            # trim side_pots to only include the non-empty side pots
            temp_pots = [pot for pot in self._side_pots if pot > 0]

            # compute who wins each side pot and pay winners
            for pot_idx, _ in enumerate(temp_pots):
                # print('players last pots', [(p.playerID, p.lastsidepot) for p in players])

                # find players involved in given side_pot, compute the winner(s)
                pot_contributors = [
                    p for p in players if p.lastsidepot >= pot_idx
                ]
                winning_rank = min([p.handrank for p in pot_contributors])
                winning_players = [
                    p for p in pot_contributors if p.handrank == winning_rank
                ]

                for player in winning_players:
                    split_amount = int(self._side_pots[pot_idx] /
                                       len(winning_players))
                    if not self._quiet:
                        print(
                            'Player', player.playerID, 'wins side pot (',
                            int(self._side_pots[pot_idx] /
                                len(winning_players)), ')')
                    player.refund(split_amount)
                    self._side_pots[pot_idx] -= split_amount

                # any remaining chips after splitting go to the winner in the earliest position
                if self._side_pots[pot_idx]:
                    earliest = self._first_to_act(
                        [player for player in winning_players])
                    earliest.refund(self._side_pots[pot_idx])
コード例 #2
0
ファイル: playercontrol.py プロジェクト: noname72/holdemq
    def print_table(self, table_state):
        print('Stacks:')
        players = table_state.get('players', None)
        for player in players:
            print(player[4], ': ', player[1], end='')
            if player[2] == True:
                print('(P)', end='')
            if player[3] == True:
                print('(Bet)', end='')
            if player[0] == table_state.get('button'):
                print('(Button)', end='')
            if players.index(player) == table_state.get('my_seat'):
                print('(me)', end='')
            print('')

        print('Community cards: ', end='')
        Card.print_pretty_cards(table_state.get('community', None))
        print('Pot size: ', table_state.get('pot', None))

        print('Pocket cards: ', end='')
        Card.print_pretty_cards(table_state.get('pocket_cards', None))
        print('To call: ', table_state.get('tocall', None))
コード例 #3
0
ファイル: playercontrol.py プロジェクト: alexbeloi/nn-holdem
    def print_table(self, table_state):
        print("Stacks:")
        players = table_state.get("players", None)
        for player in players:
            print(player[4], ": ", player[1], end="")
            if player[2] == True:
                print("(P)", end="")
            if player[3] == True:
                print("(Bet)", end="")
            if player[0] == table_state.get("button"):
                print("(Button)", end="")
            if players.index(player) == table_state.get("my_seat"):
                print("(me)", end="")
            print("")

        print("Community cards: ", end="")
        Card.print_pretty_cards(table_state.get("community", None))
        print("Pot size: ", table_state.get("pot", None))

        print("Pocket cards: ", end="")
        Card.print_pretty_cards(table_state.get("pocket_cards", None))
        print("To call: ", table_state.get("tocall", None))
コード例 #4
0
import numpy as np 

from deuces.deuces import Card

board = [
    Card.new('Ah'),
    Card.new('Kd'),
    Card.new('Jc')
]
hand = [
   Card.new('Qs'),
   Card.new('Th')
]

Card.print_pretty_cards(board + hand)
コード例 #5
0
from deuces.deuces import Card, Deck
from pokermodules.nuts import nut_hand
from sys import argv

if '--test' in argv:
    pause = False
else:
    pause = True

for i in range(15):
    deck = Deck()
    flop = deck.draw(3)
    turn = [deck.draw(1)]
    river = [deck.draw(1)]
    for board in [flop, flop + turn, flop + turn + river]:
        Card.print_pretty_cards(board)
        if pause:
            dummy = raw_input('Think hard... ')
        print "Nuts:", nut_hand(board)
    print