-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
34 lines (27 loc) · 835 Bytes
/
main.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
from game_mechanics import Game, Player
from strategies import strat1
import random
# In this simple example, both Alice and Bob play the same strategy.
# However, since Alice gets the first turn of the game, she has the advantage.
# Set random seed if desired
seed = None
# Set the number of games to simulate
repeats = 1000
# No need to modify below here
random.seed(seed)
results = {}
for i in range(repeats):
alice = Player("Alice", strat1)
bob = Player("Bob", strat1)
players = [alice, bob]
game = Game(players)
winners, scores = game.play()
if len(winners) == 1:
winner = winners[0]
else:
winner = "Draw"
results.setdefault(winner, 0)
results[winner] += 1
print("Win Percentage")
for name, wins in sorted(results.items()):
print(f"{name} = {100 * wins / repeats}%")