forked from erudnick-cohen/Pokemon-Crystal-Item-Randomizer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestExtremeHiddenAssumedFill2.py
74 lines (65 loc) · 2.71 KB
/
TestExtremeHiddenAssumedFill2.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
from contextlib import contextmanager
import sys, os, time
import RunCustomRandomizationAssumedFill as RunCustomRandomization
import yaml
import json
from shutil import copyfile
import locations_dict
@contextmanager
def suppress_stdout_stderr():
with open(os.devnull, "w") as devnull:
old_stdout = sys.stdout
sys.stdout = devnull
old_stderr = sys.stderr
sys.stderr = devnull
try:
yield
finally:
sys.stdout = old_stdout
sys.stderr = old_stderr
def print_dict(mydict):
for key in mydict.keys():
value = mydict[key]
print(str(key) + ":" + str(value))
with suppress_stdout_stderr():
romPath = 'testTrickyAgainBase - Copy.gbc'
copyfile(romPath, 'Hmmm'+romPath)
yamlfile = open("Modes/Extreme.yml")
yamltext = yamlfile.read()
settings = yaml.load(yamltext, Loader=yaml.FullLoader)
yamlfile = open(settings['BasePatch'])
yamltext = yamlfile.read()
patches = json.loads(yamltext)
modFileList = settings['DefaultModifiers']
modFileList.append('Modifiers/HiddenItems.yml')
modList = []
plandoPlacements = {}
CoreProgress = ['Surf','Fog Badge', 'Pass', 'S S Ticket', 'Squirtbottle']
for i in modFileList:
yamlfile = open(i)
yamltext = yamlfile.read()
modList.append(yaml.load(yamltext, Loader=yaml.FullLoader))
locs = locations_dict.locs
print('Finished initialization')
starttime = time.time()
for run in range(3000):
currstarttime = time.time()
with suppress_stdout_stderr():
res = RunCustomRandomization.randomizeRom('Hmmm'+romPath,settings['Goal'], settings['FlagsSet'],patches, banList = settings['BannedLocations'], allowList = settings['AllowedLocations'], modifiers = modList, plandoPlacements = plandoPlacements, coreProgress = CoreProgress, otherSettings = {'BadgeItemShuffle':None})
itemsToFind = ['Surf', 'Fog Badge']
for x in range(len(itemsToFind)):
curr_item = itemsToFind[x]
curr_location = res[1][curr_item]
if curr_location in locs.keys():
locs[curr_location] += 1
else:
print('Error: Missing ' + curr_location)
currendtime = time.time()
currdiff = currendtime - currstarttime
currtotaldiff = currendtime - starttime
curravg = currtotaldiff / (run + 1)
print("Run: " + str(run) + ", " + f'{currdiff:.2f}' + " sec" + ", " + f'{curravg:.2f}' + " sec avg")
print_dict(locs)
endtime = time.time()
timediff = endtime - starttime
print(f'{timediff:.2f}' + ' sec')