-
Notifications
You must be signed in to change notification settings - Fork 3
/
test.py
46 lines (40 loc) · 1.35 KB
/
test.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
from driver import GameDriver
from knowledge_based_agent import KBAgentRogue
from utils import InvalidMapError
if __name__ == '__main__':
height, width = 10, 10
num_powerups = 2
num_monsters = 1
num_dynamic_monsters = 1
initial_strength = 100
map_type = 'ascii'
save_dir = 'map1/'
map_file = None
show_map = False
verbose = False
results = []
for _ in range(100):
agent = KBAgentRogue(height, width, initial_strength)
agents = [agent, ]
game_driver = GameDriver(
height=height, width=width,
num_powerups=num_powerups,
num_monsters=num_monsters,
num_dynamic_monsters=num_dynamic_monsters,
agents=agents,
initial_strength=initial_strength,
show_map=show_map, map_type=map_type,
save_dir=save_dir, map_file=map_file)
print('Starting game')
try:
game_driver.play(verbose=verbose)
except InvalidMapError as e:
continue
except StopIteration as e:
if 'won' in e.value:
results.append(True)
else:
results.append(False)
won_count = sum([1 for x in results if x == True])
die_count = sum([1 for x in results if x == False])
print('Winning props: %.8f' % (won_count / float(won_count + die_count)))