View difference between Paste ID: n1wDRcuF and mxrdBWW5
SHOW: | | - or go back to the newest paste.
1
import random
2
import math
3
4
def play(totals, player, win, can_attack, hand):
5
    if win != -1:
6
        return totals, win, can_attack, hand[player]
7
    else:
8
        for i in range(3):
9
            tar = math.floor(random.random() * float(len(totals[0]) + len(totals[1])))
10
            if ((tar < len(totals[0])) and (len(totals[0]) < 9)):
11
                totals[0][tar] -= 1
12
                if ((totals[0][tar] == 0) and (tar != 0)):
13
                    totals[0].pop(tar)
14
                    can_attack[0].pop(tar)
15-
                elif ((totals[0][tar] == 0) and (tar == 0)):
15+
                elif ((totals[0][tar] == 0) and (tar <= 0)):
16
                    totals[player].append(2)
17
                    return totals, 1, can_attack, (hand[player]-1)
18
            elif ((tar >= len(totals[0])) and (len(totals[0]) < 9)):
19
                totals[1][tar-len(totals[0])] -= 1
20
                if ((totals[1][tar-len(totals[0])] == 0) and ((tar-len(totals[0])) != 0)):
21
                    totals[1].pop(tar-len(totals[0]))
22
                    can_attack[1].pop(tar-len(totals[0]))
23-
                elif ((totals[1][tar-len(totals[0])] == 0) and ((tar-len(totals[0])) == 0)):
23+
                elif ((totals[1][tar-len(totals[0])] == 0) and ((tar-len(totals[0])) <= 0)):
24
                    totals[player].append(2)
25
                    return totals, 0, can_attack, (hand[player]-1)
26
            else:
27
                return totals, -1, can_attack, hand
28
        totals[player].append(2)
29
        can_attack[player].append(False)
30
        return totals, -1, can_attack, (hand[player]-1)
31
32
def attack(can_attack, player):
33
    dmg = 0
34
    for i in can_attack[player]:
35
        if i:
36
            dmg += 3
37
    return dmg
38
39
def wakeup(can_attack, player):
40-
    for i in range(len(can_attack[player])):
40+
    for i in range(1,len(can_attack[player])):
41
        if not can_attack[player][i]:
42
            can_attack[player][i] = True
43
    return can_attack
44
45
def hero_power(totals, player, toon):
46
    if toon == "huntard":
47-
iterations = 10
47+
        totals[int(math.cos((math.pi/2.0) * player))][0] -= 2
48
    elif toon == "wario":
49
        totals[player][0] += 2
50
    else:
51
        return totals
52
    return totals
53
54
win_counter = 0
55
turn_counter = 0
56
iterations = 10000
57
toon = ["wario", "huntard"]
58
59
for i in range(iterations):
60
    boards = [[30], [30]]
61-
            if hand_size[0] > 0:
61+
62
    mana = 2
63
    win = -1
64
    n=2
65
    hand_size = [5,5]
66
    
67
    boards, win, attack_list, hand_size[1] = play(boards, 1, win, attack_list, hand_size)
68
    while win == -1:
69
        attack_list = wakeup(attack_list, 0)
70
        hand_size[0] += 1
71-
            if hand_size[1] > 0:
71+
             
72-
                boards, win, attack_list, hand_size[1] = play(boards, 1, win, attack_list, hand_size)
72+
        hp = True
73
        for i in range(math.floor(mana/2)):
74
            if (((math.floor(mana/2) - 1) > hand_size[0]) and hp):
75
                boards = hero_power(boards, 0, toon[0])
76
                hp = False
77
            elif hand_size[0] > 0:
78
                boards, win, attack_list, hand_size[0] = play(boards, 0, win, attack_list, hand_size)
79
        boards[1][0] -= attack(attack_list, 0)
80
        if boards[1][0] <= 0:
81
            win = 0
82
        n += 1
83
        
84
        attack_list = wakeup(attack_list, 1)
85
        hand_size[1] += 1
86
        hp = True
87
        for i in range(math.floor(mana/2)):
88
            if (((math.floor(mana/2) - 1) > hand_size[1]) and hp):
89
                boards = hero_power(boards, 1, toon[1])
90
                hp = False            
91
            elif hand_size[1] > 0:
92
                boards, win, attack_list, hand_size[1] = play(boards, 1, win, attack_list, hand_size)     
93
        boards[0][0] -= attack(attack_list, 1)
94
        if boards[0][0] <= 0:
95
            win = 1
96
        n += 1
97
98
        mana += 1
99
        
100
    win_counter += win
101
    turn_counter += n
102
    
103
print("coin winrate: " + str(100.0 * (float(win_counter)/float(iterations))) + "\navg turn count: " + str(float(turn_counter)/float(iterations)) + "\ntested over " + str(iterations) + " iterations")