-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathheads_up.py
47 lines (34 loc) · 1.08 KB
/
heads_up.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
import sys, getopt, math, datetime
import game
def main(argv):
if not argv:
p1 = 'human'
p2 = 'random'
elif len(argv) == 1:
p1 = 'human'
p2 = argv[0]
else:
p1 = argv[0]
p2 = argv[1]
show_output = True if len(argv) > 2 else False
# For interactive testing: python3 heads_up.py human agent
# For initial training: python3 heads_up.py agent omniscient
# For later training: python3 heads_up.py agent agent
newgame = game.Game([p1, p2], show_output=show_output)
newgame.play_game()
if p1 == "agent" and p2 in ["cheater", "omniscient"]:
num_hands = []
while True:
nh = newgame.play_game()
print(nh)
num_hands.append(nh)
if p1 == p2 and p1 == "agent":
num_hands = []
for _ in range(10000):
nh = newgame.play_game()
print(nh)
num_hands.append(nh)
with open('results.txt', 'w') as resultsfile:
resultsfile.write(str(num_hands))
if __name__ == "__main__":
main(sys.argv[1:])