Esempio n. 1
0
def play_hand(players, cards):

    # state is a number between 0 and 12
    state = betting.root()

    # get all players to look at their starting hand
    for i in range(3):
        players[i].start_hand(i, cards[i])

# start betting round
    while not betting.is_terminal(state):
        player = betting.actor(state)
        action = players[player].act(state, cards[player])
        state = betting.act(state, action)

# calculate showdown
    shown_cards = [
        cards[i] if betting.at_showdown(state, i) else None for i in range(3)
    ]

    for i in range(3):
        players[i].end_hand(i, cards[i], state, shown_cards)

    the_winner = winner(state, cards)
    pot_size = betting.pot_size(state)

    return (state, [
        pot_size * (i == the_winner) - betting.pot_contribution(state, i)
        for i in range(3)
    ])
Esempio n. 2
0
def play_hand(players, cards):
    state = betting.root()

    for i in range(3):
        players[i].start_hand(i, cards[i])

    while not betting.is_terminal(state):
        player = betting.actor(state)
        action = players[player].act(state, cards[player])
        state = betting.act(state, action)

    shown_cards = [
        cards[i] if betting.at_showdown(state, i) else None for i in range(3)
    ]

    for i in range(3):
        players[i].end_hand(i, cards[i], state, shown_cards)

    the_winner = winner(state, cards)
    pot_size = betting.pot_size(state)

    return (state, [
        pot_size * (i == the_winner) - betting.pot_contribution(state, i)
        for i in range(3)
    ])
Esempio n. 3
0
def winner(state, cards):
	assert betting.is_terminal(state)
	if betting.is_showdown(state):
		best_player = -1
		best_card   = -1
		for i in range(3):
			if betting.at_showdown(state, i) and cards[i] > best_card:
				best_player = i
				best_card   = cards[i] 
		return best_player
	else:
		return betting.bettor(state)
Esempio n. 4
0
def winner(state, cards):
    assert betting.is_terminal(state)
    if betting.is_showdown(state):
        best_player = -1
        best_card = -1
        for i in range(3):
            if betting.at_showdown(state, i) and cards[i] > best_card:
                best_player = i
                best_card = cards[i]
        return best_player
    else:
        return betting.bettor(state)
Esempio n. 5
0
def play_hand(players, cards):
	state = betting.root()

	for i in range(3):
		players[i].start_hand(i, cards[i])

	while not betting.is_terminal(state):
		player = betting.actor(state)
		action = players[player].act(state, cards[player])
		state  = betting.act(state, action)

	shown_cards = [betting.at_showdown(state, i) and cards[i] or None for i in range(3)]

	for i in range(3):
		players[i].end_hand(i, cards[i], state, shown_cards)

	the_winner = winner(state, cards)
	pot_size   = betting.pot_size(state)

	return (state, [pot_size*(i == the_winner) - betting.pot_contribution(state, i) for i in range(3)])