X-Git-Url: http://git.treefish.org/~alex/shutbox.git/blobdiff_plain/70778cce9483af1908b216ca4cd54c791490d948..25f4f9302ebf442544346d123eab4d8c8ed26044:/src/random-agent.py diff --git a/src/random-agent.py b/src/random-agent.py new file mode 100755 index 0000000..d9354a1 --- /dev/null +++ b/src/random-agent.py @@ -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)