Example #1
0
    def main(self):
        """
        ゲーム全体(ポーカー + ダブルアップチャンス)
        """
        can_play_game = True

        while can_play_game:

            # ゲームごとにplayer情報リセット
            player = Player()

            # 山札セット(セット数を決める) = ゲームごとに山札再構築
            deck = stock.Deck()
            poker = Poker(deck, player)
            poker.main_game()

            # 役ありはダブルアップチャンス
            print(player.is_poker_win)
            if player.is_poker_win:
                bonus_game = DoubleUp(player)
                bonus_game.main_game()

            # ゲームリスタート
            restart_msg = "Qでゲーム終了、それ以外でゲームスタート:"
            start_res = input(restart_msg)
            if start_res == 'Q':
                can_play_game = False
Example #2
0
 def __init__(self):
     self.users = set()
     self.poker = Poker()
     self.in_game = False
     self.pause = False
     self.pause_time = 10
     self.pause_start = 0
     self.play_time = 30
     self.play_start = 0
Example #3
0
 def __init__(self, near, room_id, ui):
     self.ui = ui
     self.room_id = room_id
     self.near = near
     self.poker = Poker(near, room_id)
     self.player_id = None
     self.cards = []
     self.load()
     super().__init__()
Example #4
0
def main():
    poker_game = Poker()
    player_one = raw_input('Player one playing? (y/n) ')
    player_two = raw_input('Player two playing? (y/n) ')
    if player_one == 'y' or player_one == 'Y':
        player_one_hand = poker_game.get_hand()
        player_one_rank = poker_game.classify_hand(player_one_hand)
        print('Player one: ', player_one_rank)
    if player_two == 'y' or player_two == 'Y':
        player_two_hand = poker_game.get_hand()
        player_two_rank = poker_game.classify_hand(player_two_hand)
        print('Player 2', player_two_rank)
        poker_game.compare_hands(player_one_hand, player_two_hand)
Example #5
0
def main():
    po = Poker()

    hero_pos = input('HERO (BTN or BB):')
    if hero_pos == 'BTN' or hero_pos == 'btn':
        hero_pos = 'BTN'
    else:
        hero_pos = 'BB'
    villan_pos = input('VILLAN (Those who are not heroes):')
    if villan_pos == '':
        if villan_pos == 'BTN':
            villan_pos = 'BB'
        else:
            villan_pos = 'BTN'
    print('BTNopen')
    act_str = input('BB 3bet or call :')
    if act_str == '3bet' or act_str == '3':
        act = 3
        if hero_pos == 'BTN':
            hero = np.where(BTNopen==3, 1, 0)
            villan = np.where(BBvsBTN>=3, 1, 0)
        else:
            villan = np.where(BTNopen==3, 1, 0)
            hero = np.where(BBvsBTN>=3, 1, 0)
    else:
        act = 2
        if hero == 'BTN':
            hero = np.where(BTNopen>=2, 1, 0)
            villan = np.where(BBvsBTN==2, 1, 0)
        else:
            hero = np.where(BTNopen>=2, 1, 0)
            villan = np.where(BBvsBTN==2, 1, 0)

    print('hero')
    print(hero)
    print('villan')
    print(villan)
    hero_prb = po.set_player(hero)
    villan_prb = po.set_player(villan)

    po.set_board(input('flop board(ex: QhJhTh): '))
    hero_df = po.create_df(hero_prb)
    villan_df = po.create_df(villan_prb)
    print('hero_df', hero_pos)
    print(hero_df)
    print('villan_df', villan_pos)
    print(villan_df)

    '''a_hit = np.sum(a_prb*(~pair), axis=0) + np.sum(a_prb*(~pair), axis=1)
Example #6
0
    def rate(player_cardgroup_2, pool):
        poker = Poker(1)

        player_value, _ = TexasHoldem.max_value(player_cardgroup_2, pool)

        win_times = 0
        times = 0
        for li in TexasHoldem.to2(52):
            cardgroup = CardGroup()
            for i, v in enumerate(li):
                if v:
                    cardgroup.append(poker.cards[i])
            if not cardgroup.is_req(pool):
                value, _ = TexasHoldem.max_value(cardgroup, pool)
                if value < player_value:
                    win_times += 1
                times += 1
            #print(win_times, times)
        return win_times, times
Example #7
0
    def game(self, debug=False):
        # print('Game #############')
        poker = Poker(1)
        poker.shuffle()

        pool = CardGroup()
        for player in self.players:
            player.clear()

        for _ in range(2):
            for player in self.players:
                player.append(poker.pop())

        for _ in range(2):
            pool.append(poker.pop())

        scores = {}
        for player in self.players:
            scores[player] = 0

        for _ in range(3):
            pool.append(poker.pop())
            values = {}
            values['min_score'] = 0
            for player in self.players:
                score = player.step(values)

                if score > values['min_score']:
                    scores[player] += score
                    values['min_score'] = score
                elif score == values['min_score']:
                    scores[player] += score

        win_player = None
        win_value = 0
        for player in self.players:
            max_value, _ = self.max_value(player.get_cardgroup(), pool)
            if win_value < max_value:
                win_player = player
                win_value = max_value

        win_player.win(sum(scores.values()))
Example #8
0
def main():
    #create a poker object
    thePoker = Poker()
    #shuffle this poker
    thePoker.shuffle()
    for cards in thePoker.cards:
        cards.makeShowCase()
    #create a rule object
    #texasHoldem = Rule()
    #create new players
    players = [Player('东邪'), Player('西毒'), Player('南帝'), Player('北丐')]
    #for _ in range(5):
    for i in range(0, 5):
        for player in players:
            player.getCard(thePoker.next())
            print("Cards before arrange: ")
            player.showCardsInHand()
            print("")
    #newArr = sorted(players,reverse=True)

    for player in players:
        #: arrange players' cardsInHand
        player.arrange()
        print("Cards after arrange: ")
        player.showCardsInHand()
        player.findType()
        player.ifFlushStraight()
        print("")

    newArr = sorted(players, reverse=True)

    for i in newArr:
        print(i.name + ': ' + i._cardsType, end=' ' + '\n')
        i.showCardsInHand()

    print('\n' + 'Winner is: ' + newArr[0].name + 'with ' +
          newArr[0]._cardsType)
Example #9
0
from player import Player
from poker import Poker

if __name__ == "__main__":
    p1 = Player('P1', 1000)
    p2 = Player('P2', 1000)

    poker = Poker()
    poker.register_player(p1)
    poker.register_player(p2)

    poker.start_game()
    poker.deliver()

    poker.reveal_card()
    poker.reveal_card()
    poker.reveal_card()
    poker.reveal_card()
    poker.reveal_card()

    win, score = poker.winner()
    if win.name == 'P1':
        print('{} -> {}'.format(
            [str(c) for c in (win.cards + poker.table_cards)], score))
Example #10
0
import os
from poker import Poker

def test_place(first_deck, second_deck):
  game = poker.Poker(first_deck, second_deck)
  print game.test()


f = open(os.path.expanduser("~/Documents/Development/Python/Project/Euler/input/54.txt"), "r")

first_decks = []
second_decks = []

while True:
    line = f.readline()
    if not line: break

    match = line.strip('\n').split(" ")

    first_decks.append(match[:5])
    second_decks.append(match[5:])


poker_game = Poker(first_decks, second_decks)
print poker_game.play()
Example #11
0
        print("Invalid number.")
    if players == 0:
        print("No.")
        players == None

while choice != 0:
    print("Select a Game: ")
    print(" 1 - Blackjack")
    print(" 2 - Poker")
    print(" 3 - Yahtzee")
    print(" 0 - Exit")
    try:
        choice = int(input(" > "))
    except ValueError:
        print("That is not a valid input. Please try again.")
        continue

    if choice == 0:
        print("Goodbye.")
    elif choice == 1:
        Blackjack(players)
    elif choice == 2:
        if players < 3:
            print("Two few players.")
            continue
        Poker(players)
    elif choice == 3:
        Yahtzee(players)
    else:
        print("That is not a valid input. Please try again.")
Example #12
0
k = (raw_input("Enter initial money of each players(as least 20 dollars):"))
while (not k.isdigit()):
    print "error,you must input a number,the number of each round must be as least 20 dollars"

    k = raw_input("Enter number of each round: ")
k = int(k)
while (k < 20):
    print ""
    print "error,you must input a number,the number of each round must be as least 20 dollars"
    k = raw_input("Enter number of each round: ")
    if k.isdigit():
        k = int(k)
money_of_each_player = float(k)
#--------------------------------------------------------------
poker = []
poker.append(Poker(number_of_players, money_of_each_player, debug))
#-------input judgement part----------------------------------
k = []
k = (raw_input("Enter round of game:"))
while (not k.isdigit()):
    print "error,you must input a number,the number of players at least be 1"

    k = raw_input("Enter round of game: ")
k = int(k)
while (k < 1):
    print ""
    print "error,you must input a number,the number of players at least be 1"
    k = raw_input("Enter round of game: ")
    if k.isdigit():
        k = int(k)
round_amount = k
Example #13
0
 def __init__(self, pok=None, dz=False, count=0):
     self.pok = pok if pok else Poker()
     self.dz = dz
     self.count = count
Example #14
0
 def __init__(self, up=None, my=None, down=None, last=None):
     self.up = up if up else Player()
     self.my = my if my else Player()
     self.down = down if down else Player()
     self.last = last if last else Poker()
Example #15
0
 def setUp(self):
     p1 = Player('P1', 1000)
     p2 = Player('P2', 1000)
     self.poker = Poker([p1, p2])