进行扑克游戏的伪代码

Pseudocode for progressing a poker game

我正在创建一个名为 progress() 的函数,它会在玩家行动后调用。

我认为结束扑克游戏只有 3 种可能的方式:

这是当前的伪代码:

Determine 'players in game' (i.e. players who hasn't folded)
If there are two or more players in game
    If there are players who hasn't acted
        Start next player turn
    Else (all players has acted)
        If all players all-in, OR all players ALL-IN except one player
        (If there are less than one player who can act)
            Ends game fast-forward: showdown and determine winners
        Else (two or more players who didn't act ALL-IN)
            If this round is last round ('River')
                Ends game normally: showdown and determine winners
            Else
                Begin next round
Else (there is only one player in game)
    Ends game abruptly: that one remaining player wins

有什么我遗漏的吗?

我认为重要的是考虑下注轮次,而不是 游戏整体。一手扑克牌是一系列下注回合。在 每轮开始,发一些牌,选择一些玩家 先行动,然后按顺序拜访玩家,直到回合结束。

在您需要保留的数据中(很多)是 在当前回合中最近一次加注的玩家(称他为 "the agressor" 即使它可能只是大盲),而且 数量。结束一轮下注的动作是:

  1. 玩家跟注。下一个玩家是侵略者。 结束回合,继续游戏。

  2. 一名玩家弃牌。下一个玩家是侵略者。

    一个。如果不止一个玩家有牌和未下注的钱,则结束这一轮, 继续正常游戏。

    b。如果有两名或更多符合条件的球员仍然存在,但除了侵略者之外的所有人 全入,结束回合,继续比赛,但不再下注。

    c。如果只有侵略者有牌,结束游戏和回合。 不要再发牌了。

如果游戏之前没有被 (2c) 结束,那么在结束之后 最后一轮下注、摊牌、奖池。

(注意:这里的小例外是现场盲注和跨栏,所以 加上那一点。还有一些特殊情况的代码,用于多于跟注但少于加注的情况。

在伪代码中:

for each hand:
    set "bluff" flag to false
    clear all betting data

    for each round:
        if "bluff", break
        deal some cards
        while true:
            visit each player
                either force his action, or offer choices
                if his action ends the round:
                    if it also ends the game (2c), set "bluff"
                    break (end round)

    if "bluff", award all to bluffer.
    else showdown, award pots as required