]> git.treefish.org Git - shutbox.git/blobdiff - src/random-agent.py
added random agent
[shutbox.git] / src / random-agent.py
diff --git a/src/random-agent.py b/src/random-agent.py
new file mode 100755 (executable)
index 0000000..d9354a1
--- /dev/null
@@ -0,0 +1,23 @@
+#!/usr/bin/env python3
+
+from game import Game
+import random
+
+def play_game():
+    g = Game()
+    while not g.is_over():
+        g.dice()
+        options = g.get_options()
+        if len(options) > 0:
+            choice = random.randint(0, len(options) - 1)
+            g.shut(options[choice])
+    return g.get_score()
+
+avg_score = 0.0
+
+for i in range(0, 10000):
+    avg_score += play_game()
+
+avg_score /= 10000
+
+print(avg_score)