0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

デュエル・マスターズ工学(デドダムの確率)

Posted at

コードの目的

  • 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%}")

結果例(実行時の出力)

image.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?