12人狼人杀位置学
这6个条件至少满足4个的概率高达96%,显著性明显
- 神狼民必三行
如图所示数字为玩家号码,神狼民必三行,说的是三条轴线的其中一条的某一边,会出现三神,三狼,三民。也就是说,下面的6各种上色号码组合中,会出现
- 三神,
- 三狼,
- 三民。
还不清楚的可以B站找相关解说。
- 上中下必产狼
上中下必产狼,说的是,
- #1,7,4,10 至少一狼,
- #2,8,2,11 至少一狼,
- #3,9,6,12 至少一狼,
绝大多数下这6个条件至少满足4个,这就是所谓的位置学。
概率统计
本想用排列组合来计算,想起身为程序员,怎么能这么蠢呢,直接试100000次看看就知道了呗。
思路:用一个数组表示牌,0表示狼,1表示民,2表示神。
- 洗牌
- 计算条件满足情况
- 统计结论:
6个条件满足:43%
5个条件满足:38%
4个条件满足:15%
这6个条件至少满足4个的概率高达96%,显著性明显
代码:
import numpy as np
import time
card = [0,0,0,0,1,1,1,1,2,2,2,2]
def card_make():
try_times = 5
while try_times > 0 :
try_times -= 1
ns = time.time_ns()
np.random.seed(ns%100000000)
card_index=np.random.randint(low=0,high=11,size=12)
for i in range(12):
temp = card[i]
card[i] = card[card_index[i]]
card[card_index[i]] = temp
def isshenglangming_3hang(cards):
num = 0
hang1 = [cards[0],cards[1],cards[2],cards[6],cards[7],cards[8]]
hang2 = [cards[3],cards[1],cards[2],cards[9],cards[7],cards[8]]
hang3 = [cards[3],cards[4],cards[2],cards[9],cards[10],cards[8]]
hang4 = [cards[3],cards[4],cards[5],cards[9],cards[10],cards[11]]
hang5 = [cards[4],cards[5],cards[0],cards[10],cards[11],cards[6]]
hang6 = [cards[0],cards[1],cards[5],cards[6],cards[7],cards[11]]
hang = [hang1,hang2,hang3,hang4,hang5,hang6]
for item in hang:
if item.count(0)==3 :
num += 1
break
for item in hang:
if item.count(1)==3 :
num += 1
break
for item in hang:
if item.count(2)==3 :
num += 1
break
return num
def isshangzhongxia(cards):
num = 0
if 0 in [cards[0],cards[6],cards[3],cards[9]]:
num += 1
if 0 in [cards[1],cards[7],cards[4],cards[10]]:
num += 1
if 0 in [cards[3],cards[9],cards[5],cards[11]]:
num += 1
return num
if __name__ == '__main__':
count = [0,0,0,0,0,0,0]
test_times = 1000000
do_times = test_times
while do_times > 0:
do_times -= 1
card_make()
match_num = isshenglangming_3hang(card)+isshangzhongxia(card)
count[match_num] += 1
print("END")
print("HAVE TRY %d TIMES" % test_times)
print("all match: %f" % np.true_divide(count[6],test_times))
print(" 5 match: %f" % np.true_divide(count[5],test_times))
print(" 4 match: %f" % np.true_divide(count[4],test_times))
print(" 3 match: %f" % np.true_divide(count[3],test_times))
print(" 2 match: %f" % np.true_divide(count[2],test_times))
print(" 1 match: %f" % np.true_divide(count[1],test_times))
print(" 0 match: %f" % np.true_divide(count[0],test_times))
如与你有助,可随手点赞,有任何问题,可与我交流,共同成长。