Closed2

among us

さざんかぬふさざんかぬふ
import random

# vote
crue_won = 0
test_count = 10000
for i in range(test_count):
    members = [1, 1, 0, 0, 0, 0, 0]
    while sum(members) > 0 and sum(members) * 2 < len(members):
        vote_decided = False
        vote_result = []
        while not vote_decided:
            vote_dict = {}
            for i in members:
                decided = False
                while not decided:
                    candidate = random.randint(0, len(members) - 1)
                    decided = not (i and members[candidate])
                vote_dict[candidate] = vote_dict.get(candidate, 0) + 1
            vote_result = sorted([(k, v) for k, v in vote_dict.items()], key=lambda x: x[1])
            vote_decided = len(vote_result) == 1 or (vote_result[-1][1] != vote_result[-2][1])
            print(vote_dict)
        print(f'kill: {vote_result[-1][0]}')
        members.pop(vote_result[-1][0])
    if sum(members) == 0:
        crue_won += 1

print(f'crues won {crue_won} / {test_count}')

crues won 1086 / 10000
crues won 1108 / 10000
crues won 1113 / 10000

11%ぐらい?

このスクラップは2021/08/02にクローズされました