コードの目的
- 40枚デッキの中に《デドダム》を4枚入れた構成で、
- 初期7枚(手札5枚+2ターンドロー)に
- デドダム1枚
- 水・闇・自然の3文明が1枚ずつある
- という条件を満たす確率をPythonシミュレーションで試算します。
プログラムコード
import random
# --- デッキ構成の設定 / Define deck composition ---
deck_size = 40 # デッキ枚数 / total number of cards in the deck
trials = 100000 # 試行回数 / number of simulations
deck = (
['デドダム'] * 4 + # デドダム4枚 / 4 copies of Dedodam
['水'] * 10 + # 水文明カード10枚 / 10 water cards
['闇'] * 10 + # 闇文明カード10枚 / 10 darkness cards
['自然'] * 10 + # 自然文明カード10枚 / 10 nature cards
['その他'] * (deck_size - 4 - 10 - 10 - 10) # 残りのカード / others
)
success = 0 # デドダム召喚成功回数 / Count of successful turn-3 Dedodam plays
for _ in range(trials):
hand = random.sample(deck, 7) # 初期手札+2ターンドロー / 7 cards by turn 3
has_dedodam = 'デドダム' in hand
# 手札に存在する文明をセットで取得 / Get unique civilizations in hand
mana_pool = set(card for card in hand if card in ['水', '闇', '自然'])
# デドダムがあり、3色揃っていれば成功 / Check if Dedodam + 3 colors exist
if has_dedodam and {'水', '闇', '自然'}.issubset(mana_pool):
success += 1
# --- 成功確率の表示 / Print success probability ---
prob = success / trials
print(f"3ターン目に《天災 デドダム》を召喚できる確率:{prob:.2%}")