在扑克中查找“加注”操作是否发生在“加注”之后

Find whether the "call" action happened after the "raise" in Poker

提问人:Carol Owens 提问时间:8/9/2023 最后编辑:mkrieger1Carol Owens 更新时间:8/9/2023 访问量:45

问:

此函数的输入是翻牌时的扑克操作列表(假设这是唯一的投注街)。呵呵,该函数在此示例中确实错误地输出。然而,这不可能是真的,因为 Robert2 称 Brittney3 的赌注。no_calls_other_than_original_bettor = True

(“叫”是指他的赌注等于之前的最大赌注;“加注”意味着赌注比前一个赌注大。

def analyse_poker_actions(actions):
    players = set()
    bettor = None
    raiser = None
    call_players = []
    raise_players = []
    betting_street = None
    raise_players_excluding_bettor = []
    fold_actions = []
    bettor_actions = []
    for action in actions:
        players.add(action['player'])
        if action['action'] == 'bets':
            bettor = action['player']
            if betting_street is None:
                betting_street = action['street']
        if action['player'] == bettor:
            bettor_actions.append(action['action'])
        if action['action'] == 'calls':
            call_players.append(action['player'])
        if action['action'] == 'raises':
            raise_players.append(action['player'])
            if action['player'] != bettor:
                raise_players_excluding_bettor.append(action['player'])
                if raiser is None:
                    raiser = action['player']

        if action['action'] == 'folds':
            fold_actions.append(action['player'])

    player_bet_and_folded = bettor in fold_actions

    no_calls_other_than_original_bettor = all(player != bettor and player != raiser for player in call_players)

    cold4bet = len(set(raise_players_excluding_bettor)) > 1

    if 'raises' in bettor_actions and 'folds' in bettor_actions:
        bettor_reraised = bettor_actions.index('raises') < bettor_actions.index('folds')
    else:
        bettor_reraised = False
    return betting_street, player_bet_and_folded,no_calls_other_than_original_bettor,cold4bet, bettor_reraised, len(players),len(raise_players_excluding_bettor)

对于此测试,该函数会输出而不是 -('FLOP', True, True, False, False, 6, 1)('FLOP', True, False, False, False, 6, 1)

test1= [{'street': 'FLOP', 'player': 'John4', 'position': 4, 'action': 'checks'},
 {'street': 'FLOP', 'player': 'Jane0', 'position': 0, 'action': 'checks'}, 
{'street': 'FLOP', 'player': 'Brittney2', 'position': 2, 'action': 'bets', 'amount': 18.0},
 {'street': 'FLOP', 'player': 'Robert3', 'position': 3, 'action': 'calls', 'amount': 18.0},
 {'street': 'FLOP', 'player': 'John4', 'position': 4, 'action': 'raises', 'amount': 94.0},
 {'street': 'FLOP', 'player': 'Jane0', 'position': 0, 'action': 'folds'}, 
 {'street': 'FLOP', 'player': 'Brittney2', 'position': 2, 'action': 'folds'}, 
{'street': 'FLOP', 'player': 'Robert3', 'position': 3, 'action': 'folds'}]
python-3.x 列表 解析

评论

0赞 mkrieger1 8/9/2023
你的问题是什么?

答: 暂无答案