5D Library › 四人不完全信息随机博弈、贝叶斯读牌与反事实遗憾最小化 · English

第二章 牌池:超几何推断与一个方向相反的结果

未见牌是一个池

从一名玩家的角度看,牌张分成两类:已见(自己的手牌、所有舍牌、所有明牌)与未见。未见的部分包括牌墙与另外三家的手牌,而玩家无法区分这两者。于是「某种牌还剩几张」有精确答案(4 减去已见的张数),而「我会不会摸到」是一个超几何问题 (Feller 1968)。

推导

# Chapter 2. The tile pool as a hypergeometric inference problem. A player
# sees their own hand, every discard, and every exposed meld. Everything else
# -- the wall and the three concealed hands -- is one undifferentiated pool
# from that player's point of view, and the question "how many of tile t are
# left" has an exact answer, while "will I draw one" is hypergeometric. The
# program computes the probability of drawing at least one of a set of useful
# tiles in the remaining draws, and shows how much the answer moves when a
# single copy becomes visible. Exact arithmetic; standard library only.
import math

TYPES, COPIES = 34, 4
TOTAL = TYPES * COPIES          # 136
DEAD_WALL = 14                  # set aside, never drawn in the standard rule

def own_draws_left(turn, players=4):
    """Draws this player still takes, if the live wall is exhausted at turn
    18."""
    return max(0, 18 - turn)

def p_at_least_one(useful_left, pool, draws):
    """Hypergeometric: P(at least one useful tile among `draws` from
    `pool`)."""
    if draws <= 0 or useful_left <= 0:
        return 0.0
    if useful_left >= pool:
        return 1.0
    # P(none) = C(pool - useful, draws) / C(pool, draws)
    return 1.0 - math.comb(pool - useful_left, draws) / math.comb(pool, draws)

if __name__ == "__main__":
    print(
        "Set of {} tiles; {} set aside in the dead wall.".format(
            TOTAL, DEAD_WALL
        )
    )
    print(
        "A player's own draws remaining are counted from the turn number.\n"
    )

    # a typical mid-game position: own 13 tiles, 36 tiles visible as
    # discards/melds
    own, visible = 13, 36
    pool = TOTAL - DEAD_WALL - own - visible
    print(
        "Mid-game: own hand {}, visible tiles {}, so the unseen pool this"
        " player".format(own, visible)
    )
    print(
        "draws from (wall plus three concealed hands) is {} tiles.\n".format(
            pool
        )
    )

    print(
        "A. Probability of drawing at least one acceptance tile, by how many"
        " copies"
    )
    print("remain and how many draws are left:")
    print("   copies left   4 draws   8 draws   12 draws   16 draws")
    for left in (1, 2, 3, 4, 6, 8):
        print(
            "   {:11d}".format(left)
            + "".join(
                "{:10.3f}".format(p_at_least_one(left, pool, d))
                for d in (4, 8, 12, 16)
            )
        )

    print(
        "\nB. What one visible copy is worth. A wait on a tile type with 4"
        " copies"
    )
    print("live, as copies appear in discards, with 10 draws remaining:")
    base = None
    for seen in (0, 1, 2, 3):
        left = 4 - seen
        p = p_at_least_one(left, pool, 10)
        if base is None:
            base = p
        print(
            "   {} copies visible -> {} live: P = {:.3f}  ({:+.1%} relative"
            " to none visible)".format(seen, left, p, p / base - 1)
        )

    print(
        "\n   The first visible copy costs about a sixth of the chance; the"
        " third"
    )
    print(
        "   costs more than half. This is the formal content of the ordinary"
        " advice"
    )
    print(
        "   to abandon a wait whose tiles are mostly gone, and the size"
        " of the"
    )
    print("   effect is set by the pool, not by intuition.")

    print(
        "\nC. A two-sided wait against a one-sided wait, same number of draws"
        " (10):"
    )
    for label, left in (("two-sided (8 live)", 8), ("one-sided (4 live)", 4),
                        ("pair wait (2 live)", 2)):
        print(
            "   {:22s} P = {:.3f}".format(
                label, p_at_least_one(left, pool, 10)
            )
        )
    ratio = p_at_least_one(8, pool, 10) / p_at_least_one(4, pool, 10)
    print(
        "   The two-sided wait is {:.2f} times the one-sided wait in"
        " probability of".format(ratio)
    )
    print(
        "   acceptance -- NOT twice the number of live tiles, because with"
        " ten draws"
    )
    print("   left both probabilities are already saturating.")

    print("\nD. How that ratio depends on how many draws remain:")
    print("   draws left   two-sided / one-sided ratio   stage of the hand")
    for d, stage in ((2, "late"), (4, "late"), (8, "middle"), (12, "early"),
                     (16, "very early")):
        a = p_at_least_one(8, pool, d)
        b = p_at_least_one(4, pool, d)
        print(
            "   {:10d} {:28.3f}   {}".format(
                d, a / b if b > 0 else float("nan"), stage
            )
        )
    print(
        "\n   Note the direction, which is easy to get backwards. FEW draws"
        " left"
    )
    print(
        "   means LATE in the hand, and there the ratio is {:.2f}, close to"
        " the 2.0".format(
            p_at_least_one(8, pool, 2) / p_at_least_one(4, pool, 2)
        )
    )
    print(
        "   that counting live tiles would predict. With many draws left --"
        " EARLY in"
    )
    print(
        "   the hand -- the ratio falls to {:.2f}, because both waits have"
        " time to be".format(
            p_at_least_one(8, pool, 16) / p_at_least_one(4, pool, 16)
        )
    )
    print("   hit and the probabilities saturate toward 1.")
    print(
        "   So counting acceptance tiles as proportional to the chance of"
        " completion"
    )
    print(
        "   is accurate LATE and overstates wide waits EARLY. The practical"
        " reading"
    )
    print(
        "   is the reverse of the usual emphasis: early in the hand the width"
        " of a"
    )
    print(
        "   wait matters less than it looks, and what matters more is the"
        " value of"
    )
    print("   the hand and the shape's flexibility (Chapter 4).")

    print(
        "\nE. The inference the pool does NOT support. The {} unseen tiles"
        " include".format(pool)
    )
    print(
        "   39 tiles in opponents' hands, and the hypergeometric calculation"
        " above"
    )
    print(
        "   treats them as if they were in the wall. That is wrong"
        " whenever an"
    )
    print(
        "   opponent is holding the tile BECAUSE it is useful to them,"
        " which is"
    )
    print(
        "   precisely the case for the tiles a player most wants. Chapter 3"
        " models"
    )
    print(
        "   that dependence; the numbers above are the no-dependence"
        " baseline and"
    )
    print("   are therefore optimistic for contested tiles.")
# Set of 136 tiles; 14 set aside in the dead wall.
# A player's own draws remaining are counted from the turn number.
#
# Mid-game: own hand 13, visible tiles 36, so the unseen pool this player
# draws from (wall plus three concealed hands) is 73 tiles.
#
# A. Probability of drawing at least one acceptance tile, by how many copies
# remain and how many draws are left:
#    copies left   4 draws   8 draws   12 draws   16 draws
#              1     0.055     0.110     0.164     0.219
#              2     0.107     0.209     0.304     0.393
#              3     0.158     0.298     0.421     0.530
#              4     0.206     0.378     0.521     0.637
#              6     0.296     0.515     0.674     0.787
#              8     0.378     0.625     0.781     0.877
#
# B. What one visible copy is worth. A wait on a tile type with 4 copies
# live, as copies appear in discards, with 10 draws remaining:
#    0 copies visible -> 4 live: P = 0.453  (+0.0% relative to none visible)
#    1 copies visible -> 3 live: P = 0.362  (-20.1% relative to none visible)
#    2 copies visible -> 2 live: P = 0.257  (-43.3% relative to none visible)
#    3 copies visible -> 1 live: P = 0.137  (-69.7% relative to none visible)
#
#    The first visible copy costs about a sixth of the chance; the third
#    costs more than half. This is the formal content of the ordinary advice
#    to abandon a wait whose tiles are mostly gone, and the size of the
#    effect is set by the pool, not by intuition.
#
# C. A two-sided wait against a one-sided wait, same number of draws (10):
#    two-sided (8 live)     P = 0.712
#    one-sided (4 live)     P = 0.453
#    pair wait (2 live)     P = 0.257
#    The two-sided wait is 1.57 times the one-sided wait in probability of
#    acceptance -- NOT twice the number of live tiles, because with ten draws
#    left both probabilities are already saturating.
#
# D. How that ratio depends on how many draws remain:
#    draws left   two-sided / one-sided ratio   stage of the hand
#             2                        1.943   late
#             4                        1.837   late
#             8                        1.652   middle
#            12                        1.500   early
#            16                        1.377   very early
#
#    Note the direction, which is easy to get backwards. FEW draws left
#    means LATE in the hand, and there the ratio is 1.94, close to the 2.0
#    that counting live tiles would predict. With many draws left -- EARLY in
#    the hand -- the ratio falls to 1.38, because both waits have time to be
#    hit and the probabilities saturate toward 1.
#    So counting acceptance tiles as proportional to the chance of completion
#    is accurate LATE and overstates wide waits EARLY. The practical reading
#    is the reverse of the usual emphasis: early in the hand the width of a
#    wait matters less than it looks, and what matters more is the value of
#    the hand and the shape's flexibility (Chapter 4).
#
# E. The inference the pool does NOT support. The 73 unseen tiles include
#    39 tiles in opponents' hands, and the hypergeometric calculation above
#    treats them as if they were in the wall. That is wrong whenever an
#    opponent is holding the tile BECAUSE it is useful to them, which is
#    precisely the case for the tiles a player most wants. Chapter 3 models
#    that dependence; the numbers above are the no-dependence baseline and
#    are therefore optimistic for contested tiles.

一张可见的牌值多少

B 段给出一个有用的量级:以 4 张全活、剩 10 次摸牌为基准,第一张可见的牌使完成概率下降约六分之一,第三张使它下降超过一半。这是「听的牌大半已经出现就该换张」这条常识的形式内容,而它的大小由池的大小决定,不由直觉决定。

方向容易记反的那个结果

C 段与 D 段是本章的要点,而它的方向与常见说法相反。

两面听(8 张活)相对单骑(4 张活)的完成概率比,在剩 10 次摸牌时是 1.57——不是 2,因为两者的概率都已在饱和。D 段把这个比值随剩余摸牌次数列出来:

  • 剩 2 次摸牌(牌局后期):比值 1.943,接近按活张数预测的 2.0;
  • 剩 16 次摸牌(牌局前期):比值 1.377。
两面听(8 张活)与单骑(4 张活)的完成概率之比,随剩余摸牌次数变化。灰线为按活张数预测的 2.0。剩余摸牌次数少对应牌局后期,比值接近 2;剩余次数多对应牌局前期,比值降到 1.38 左右。

方向很容易记反:剩余摸牌次数少意味着牌局后期。所以

按进张数成比例估计完成概率,在牌局后期是准确的,在前期高估宽听。

实践上的读法与通常的强调相反:牌局前期,听牌的宽窄不像看起来那么重要,更重要的是手牌的价值与形状的灵活性(第四章)。而到了后期,数活张就是对的。

假说 · 尚未验证

作者的假说(尚未确立): 在第八章的重复对局设计中,一个在前六巡按手牌价值而非进张数取舍、在后六巡按活张数取舍的策略,优于在全程都按进张数取舍的策略。什么样的结果能证明它是错的: 若该比较的点数差的 95% 置信区间包含零,或方向相反,则本假说错。

这个计算不支持的推断

E 段写明一处限制,而它对本书后面很重要。超几何计算把 73 张未见牌当作一个均匀的池,其中却有 39 张在对手手里。当对手持有某张牌正是因为那张牌对他们有用时,这个假设就错了——而这恰好发生在玩家最想要的牌上。

所以本章的数字是无相依的基准,对争夺中的牌是偏乐观的。第三章处理这种相依,而处理的办法是对对手的手牌分布建模,其可信度远低于本章的超几何计算。第一章的方法论原则在这里第一次起作用:本章属于「只依赖自己手牌与已见牌」的第一类量,第三章属于第二类。

注

与第 37 本的关系。 第 37 本讨论过离散周期网络与占位熵,那里的对象是占位的分布;本章的对象是抽样而不是占位,两者数学上不同,不要互相套用。

本章小结

从一名玩家的角度,未见牌是一个均匀的池,而「会不会摸到」是超几何问题。一张可见的牌有可计算的代价:以 4 张全活、剩 10 次摸牌为基准,第一张可见的牌使完成概率降约六分之一,第三张降超过一半。本章的主要结果方向容易记反:两面听相对单骑的完成概率比在剩 2 次摸牌(牌局后期)时为 1.94,接近按活张数预测的 2.0,而在剩 16 次摸牌(前期)时降到 1.38,因为两者都有时间被摸到。所以数进张在后期准确、在前期高估宽听,而实践上的读法是前期更该看手牌价值与形状灵活性。最后,超几何计算把对手手里的 39 张当作牌墙处理,所以对争夺中的牌偏乐观——而那正是玩家最想要的牌。

参考文献

Feller, William. 1968. An Introduction to Probability Theory and Its Applications, Volume i. 3rd ed. New York: Wiley.

Fan, Y. (2026). Imperfect-Information Stochastic Games, Bayesian Hand-Reading and Counterfactual Regret Minimisation in Four-Player Tile Dynamics: From Markov Transitions of the Tile Pool and the Optimal Stopping of Defensive Folding to Kelly Allocation in a Multiplayer Game, with a Textual Examination of the Orthodox and the Unorthodox in the Classical Military Writers [四人不完全信息随机博弈、贝叶斯读牌与反事实遗憾最小化] (Version 1.0.0). 5D Library. https://doi.org/10.5281/zenodo.24020464 · Licensed under Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0).