用于进行扑克游戏的伪代码

时间:2015-02-04 15:48:33

标签: algorithm pseudocode poker

我正在创建一个名为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

我错过了什么吗?

1 个答案:

答案 0 :(得分:1)

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

您需要保留的数据(它很多)是其中的身份 在本轮比赛中最近加注的球员(打电话给他 " agressor"即使它可能只是大盲目),那 量。结束下注轮次的行动包括:

  1. 玩家来电。下一位选手是agressor。 结束,继续游戏。

  2. 玩家弃牌。下一位选手是agressor。

    一个。如果不止一个玩家有牌并且取消钱,最后,   继续比赛正常。

    湾如果两个或更多合格的球员仍然存在,但除了agressor之外   全部进入,结束,继续游戏,但不再投注。

    ℃。如果只有agressor有牌,结束比赛和回合。   不要再发牌了。

  3. 如果游戏之前没有以(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