import random
import numpy as np
from itertools import product, combinations
# 生成牌堆
pile = []
for i in range(1, 14):
pile += [i] * 12
pile += [5, 5, 12, 12]
def shuffle():
return random.shuffle(pile)
def simulation():
shuffle()
last_card = None
result = []
for card in pile:
result.append(card)
if last_card is None:
last_card = card
else:
if card == last_card:
break
elif card > last_card and last_card <= 7:
last_card = card
continue
elif card < last_card and last_card >= 8:
last_card = card
continue
else:
break
return result
if __name__ == '__main__':
N = 10000
r = []
for i in range(N):
result = simulation()
r.append(len(result))
mean = np.mean(r)
std = np.std(r)
m = np.max(r)
print(mean, std, m)