-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathTCGTests.py
104 lines (79 loc) · 3.22 KB
/
TCGTests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import TCGMain as tc
from modules import pyrand
def runtests():
#rngtest()
#packtest()
openpacktest('Quacker Booster', print_res=True)
def rngtest():
test_input_list = ('50', '30', '10', '5', '3', '1.5', '.5')
perfect_results = {x+'%': int(float(x)*100) for x in test_input_list}
test_input_list = [x+'%' for x in test_input_list]
test_weight_list = (.5, .3, .1, .05, .03, .015, .005)
results = {x: 0 for x in test_input_list}
print('\nTesting 10000 iterations of 1-draw weighted choice rng~~')
for x in range(10000):
testresult = pyrand.weightchoice(test_input_list, test_weight_list)
results[testresult] += 1
print(results)
results = {x: 0 for x in test_input_list}
print('\nTesting 1000 iterations of 10-draw weighted choice rng~~')
for x in range(1000):
testresults = pyrand.weightchoice(test_input_list, test_weight_list, 10)
for result in testresults:
results[result] += 1
print(results)
results = {x: 0 for x in test_input_list}
print('\nTesting 100 iterations of 100-draw weighted choice rng~~')
for test in range(100):
testresults = pyrand.weightchoice(test_input_list, test_weight_list, 100)
for result in testresults:
results[result] += 1
print(results)
print('\nPerfect results~~')
print(perfect_results)
test_input_list = [x+1 for x in range(25)]
results = {x: 0 for x in test_input_list}
print('\nTesting 100 iterations of 100-draw non-weighted 1-25 randint() choice rng~~')
for test in range(100):
testresults = pyrand.randint(1, 25, 100)
for result in testresults:
results[result] += 1
print(results)
def packtest():
print('Opening packs')
print('Testing opening packs. Opening 10 rounds of packs.\n')
for pack in tc.packs.values():
print(pack.pack_name, pack.card_amount, pack.theme_card_chance, pack.max_themed)
for x in range(10):
print('\tPack', x+1, end='\n\t\t')
cards = pack.open_pack()
for card in cards:
print(card.card_tier, card.card_name, end=', ')
print()
def strtest():
print('Generating 10 random strings with a length of 15 characters')
for x in range(15):
print(pyrand.randstring(15))
def openpacktest(pack_name, pack_amt=100, print_res=False):
try:
pack = tc.packs[pack_name]
except:
raise ValueError('Invalid pack name: {0}'.format(pack_name))
tca = pack_amt*pack.card_amount
card_list = []
tcc = 0
for x in range(pack_amt):
card_list.extend(pack.open_pack())
for card in card_list:
if card.card_theme == pack.extra_theme:
tcc += 1
del card_list
tccp = round(tcc/tca*100, 4)
if print_res:
print('Opened', pack_amt, pack_name, 'packs (', pack.card_amount, 'cards each, max', pack.max_themed,
'themed cards per pack ) whose themed card chance is', pack.theme_card_chance*100, '%')
print(tcc, 'out of', tca, 'cards were themed giving a total of', tccp, '% themed cards')
print('perfect world themed cards amount is', pack_amt * pack.max_themed)
return tcc, tccp
if __name__ == '__main__':
runtests()