]> git.treefish.org Git - shutbox.git/blob - src/random-agent.py
added random agent
[shutbox.git] / src / random-agent.py
1 #!/usr/bin/env python3
2
3 from game import Game
4 import random
5
6 def play_game():
7     g = Game()
8     while not g.is_over():
9         g.dice()
10         options = g.get_options()
11         if len(options) > 0:
12             choice = random.randint(0, len(options) - 1)
13             g.shut(options[choice])
14     return g.get_score()
15
16 avg_score = 0.0
17
18 for i in range(0, 10000):
19     avg_score += play_game()
20
21 avg_score /= 10000
22
23 print(avg_score)