我写的一个21点模拟分析
这个电音很赞啊,男主很帅,女主差点但也不错。看了别人写的分析二十一点的记牌算法很受启发。但心中还是有个疑问:如果玩家按照最优的决策方案玩牌,在不计牌的冷热情况下,玩家的胜率究竟是多大?会是50%么?为此写了一个小程序做了下模拟运算。
(这个分析不考虑桌面已有牌对于后续牌的影响,也就是说假设新出的牌从A到K出现的概率都是1/13,同时还假设当双方同时出现21点的情况时,玩家获胜)
首先定义“正确的决策方案”。当玩家手中的牌达到12点及以上时,玩家就要开始做出选择,究竟继续叫牌还是停止。
在N点上停止抓牌获胜的概率是:庄家在N点及以下所有点数抓爆的概率总和。比如玩家有14点,并停止抓拍,他获胜的可能就是:庄家在12点抓爆的概率+13点抓爆的概率+14点抓爆的概率
在N点上继续抓牌(只抓一张)获胜的概率是:玩家抓到每张不会冒的牌a的概率乘以庄家在N+a点及以下抓爆的概率。比如庄家在14点时选择继续抓牌,他获胜的概率是:
(玩家抓A的概率*(庄家在15点抓爆的概率+玩家在14点抓爆的概率))+
(玩家抓2的概率*(庄家在16点抓爆的概率+玩家在15点抓爆的概率+庄家在14点抓爆的概率)+……+
(玩家抓7的概率*(庄家在21点抓爆的概率+玩家在20点抓爆的概率+……+玩家在12点抓爆的概率))
在这里,庄家在N点抓爆的概率的含义是:如果庄家一直抓牌,直到抓爆为止,在抓爆之前的点数为N。N为特定数出现的概率为多少。这个数值可以通过计算机模拟运算近似生成。通过一千万次模拟,得出的结论是:
N = 12: P(12) = 0.030543
N = 13: P(13) = 0.0438322
N = 14: P(14) = 0.0569275
N = 15: P(15) = 0.0711665
N = 16: P(16) = 0.0864059
N = 17: P(17) = 0.102366
N = 18: P(18) = 0.1193312
N = 19: P(19) = 0.1372943
N = 20: P(20) = 0.2131834
N = 21: P(21) = 0.13895
注:当庄家出现21点时,仍然需要抓牌,表示此时玩家已经出现21点,庄家已经必输。在所有抓爆的情况中,在21点处抓爆的概率为12.895%
利用以上的数据,根据上面的公式可以分析出最优的决策方案:
if you get 12 and you stop, your chance to win is 0.0304902
If you get 12 and you continue, your chance to win is 0.31595218
if you get 13 and you stop, your chance to win is 0.07414
If you get 13 and you continue, your chance to win is 0.23902911
if you get 14 and you stop, your chance to win is 0.1311739
If you get 14 and you continue, your chance to win is 0.17278956
if you get 15 and you stop, your chance to win is 0.20239449
If you get 15 and you continue, your chance to win is 0.12294503
if you get 16 and you stop, your chance to win is 0.28873807
If you get 16 and you continue, your chance to win is 0.083663836
if you get 17 and you stop, your chance to win is 0.39118338
If you get 17 and you continue, your chance to win is 0.053572804
if you get 18 and you stop, your chance to win is 0.5106556
If you get 18 and you continue, your chance to win is 0.031362183
if you get 19 and you stop, your chance to win is 0.6479789
If you get 19 and you continue, your chance to win is 0.015793376
if you get 20 and you stop, your chance to win is 0.861114
If you get 20 and you continue, your chance to win is 0.0057030767
if you get 21 and you stop, your chance to win is 1.0
If you get 21 and you continue, your chance to win is 0.0
由此可知,当玩家手里的牌小于15点时,需要继续叫牌,否则停止。
最后是再次进行模拟,找到依据最优决策方案得到的获胜概率。
模拟的次数依然是一千万次,最终的结果是:
if you followed the right method, your chance to win is 0.45998985
也就是说,玩家正常的胜率只有46%。如果按照电影中的算法,算牌的点数每增加一点,玩家获胜的概率增加0.5%,那么点数至少需要达到8点以上才能算是热牌。然而即使点数达到了18点超级热牌,玩家的胜率也只有55%,呃。。。所以说靠技术赚大钱还是很难的。
(这个分析不考虑桌面已有牌对于后续牌的影响,也就是说假设新出的牌从A到K出现的概率都是1/13,同时还假设当双方同时出现21点的情况时,玩家获胜)
首先定义“正确的决策方案”。当玩家手中的牌达到12点及以上时,玩家就要开始做出选择,究竟继续叫牌还是停止。
在N点上停止抓牌获胜的概率是:庄家在N点及以下所有点数抓爆的概率总和。比如玩家有14点,并停止抓拍,他获胜的可能就是:庄家在12点抓爆的概率+13点抓爆的概率+14点抓爆的概率
在N点上继续抓牌(只抓一张)获胜的概率是:玩家抓到每张不会冒的牌a的概率乘以庄家在N+a点及以下抓爆的概率。比如庄家在14点时选择继续抓牌,他获胜的概率是:
(玩家抓A的概率*(庄家在15点抓爆的概率+玩家在14点抓爆的概率))+
(玩家抓2的概率*(庄家在16点抓爆的概率+玩家在15点抓爆的概率+庄家在14点抓爆的概率)+……+
(玩家抓7的概率*(庄家在21点抓爆的概率+玩家在20点抓爆的概率+……+玩家在12点抓爆的概率))
在这里,庄家在N点抓爆的概率的含义是:如果庄家一直抓牌,直到抓爆为止,在抓爆之前的点数为N。N为特定数出现的概率为多少。这个数值可以通过计算机模拟运算近似生成。通过一千万次模拟,得出的结论是:
N = 12: P(12) = 0.030543
N = 13: P(13) = 0.0438322
N = 14: P(14) = 0.0569275
N = 15: P(15) = 0.0711665
N = 16: P(16) = 0.0864059
N = 17: P(17) = 0.102366
N = 18: P(18) = 0.1193312
N = 19: P(19) = 0.1372943
N = 20: P(20) = 0.2131834
N = 21: P(21) = 0.13895
注:当庄家出现21点时,仍然需要抓牌,表示此时玩家已经出现21点,庄家已经必输。在所有抓爆的情况中,在21点处抓爆的概率为12.895%
利用以上的数据,根据上面的公式可以分析出最优的决策方案:
if you get 12 and you stop, your chance to win is 0.0304902
If you get 12 and you continue, your chance to win is 0.31595218
if you get 13 and you stop, your chance to win is 0.07414
If you get 13 and you continue, your chance to win is 0.23902911
if you get 14 and you stop, your chance to win is 0.1311739
If you get 14 and you continue, your chance to win is 0.17278956
if you get 15 and you stop, your chance to win is 0.20239449
If you get 15 and you continue, your chance to win is 0.12294503
if you get 16 and you stop, your chance to win is 0.28873807
If you get 16 and you continue, your chance to win is 0.083663836
if you get 17 and you stop, your chance to win is 0.39118338
If you get 17 and you continue, your chance to win is 0.053572804
if you get 18 and you stop, your chance to win is 0.5106556
If you get 18 and you continue, your chance to win is 0.031362183
if you get 19 and you stop, your chance to win is 0.6479789
If you get 19 and you continue, your chance to win is 0.015793376
if you get 20 and you stop, your chance to win is 0.861114
If you get 20 and you continue, your chance to win is 0.0057030767
if you get 21 and you stop, your chance to win is 1.0
If you get 21 and you continue, your chance to win is 0.0
由此可知,当玩家手里的牌小于15点时,需要继续叫牌,否则停止。
最后是再次进行模拟,找到依据最优决策方案得到的获胜概率。
模拟的次数依然是一千万次,最终的结果是:
if you followed the right method, your chance to win is 0.45998985
也就是说,玩家正常的胜率只有46%。如果按照电影中的算法,算牌的点数每增加一点,玩家获胜的概率增加0.5%,那么点数至少需要达到8点以上才能算是热牌。然而即使点数达到了18点超级热牌,玩家的胜率也只有55%,呃。。。所以说靠技术赚大钱还是很难的。
这篇影评有剧透