Untitled

mail@pastecode.io avatar
unknown
python
24 days ago
2.6 kB
9
Indexable
Never
import numpy as np
import pandas as pd

# card data
data = {
    'name': ['Recover Assets', 'Assasination', 'Cull the Horde', 'Behind', 'Area denial', 'Card6', 'Card7', 'Card8',
             'Card9', 'Card10', 'Card11', 'Card12', 'Card13', 'Card14', 'Card15', 'Card16', 'Card17', 'Card18'],
    'isAction': [1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0],
    'minVP': [3, 5, 5, 3, 2, 3, 5, 4, 6, 3, 2, 4, 5, 6, 2, 3, 1, 2],
    'maxVP': [6, 5, 5, 4, 5, 6, 5, 4, 6, 4, 5, 4, 6, 5, 4, 6, 3, 4],
    'needTurn': [1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0],
    'discard': [1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0],
    'constVP': [0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
}

cards_df = pd.DataFrame(data)

# Adjusted VP values for action cards giving 0 points
adjusted_min_vp_values = np.where(cards_df['isAction'] == 1, 0, cards_df['minVP'].values)
adjusted_max_vp_values = np.where(cards_df['isAction'] == 1, 0, cards_df['maxVP'].values)
total_draws = 2 * 5


# simulate drawing cards
def simulate_drawing_min_actions(num_simulations, min_actions_required):
    min_vp_results = []
    max_vp_results = []

    for _ in range(num_simulations):
        deck = list(range(len(cards_df)))
        drawn_cards = []
        action_card_count = 0

        while len(drawn_cards) < total_draws:
            card = np.random.choice(deck)
            if cards_df.at[card, 'isAction'] == 1:
                action_card_count += 1
                deck.remove(card)
                if len(deck) > 0:
                    replacement_card = np.random.choice(deck)
                    drawn_cards.append(replacement_card)
                    deck.remove(replacement_card)
            else:
                drawn_cards.append(card)
                deck.remove(card)
                if len(drawn_cards) == total_draws:
                    break

        if action_card_count >= min_actions_required:
            min_vp_sum = sum(adjusted_min_vp_values[drawn_cards])
            max_vp_sum = sum(adjusted_max_vp_values[drawn_cards])
            min_vp_results.append(min_vp_sum)
            max_vp_results.append(max_vp_sum)

    expected_min_vp = np.mean(min_vp_results) if min_vp_results else float('nan')
    expected_max_vp = np.mean(max_vp_results) if max_vp_results else float('nan')

    return expected_min_vp, expected_max_vp


#  20,000 sim
num_simulations = 20000
min_actions_required = 5
expected_min_vp, expected_max_vp = simulate_drawing_min_actions(num_simulations, min_actions_required)

print(f"Expected MinVP: {expected_min_vp}")
print(f"Expected MaxVP: {expected_max_vp}")
Leave a Comment