-
Notifications
You must be signed in to change notification settings - Fork 0
/
Simulator.py
36 lines (30 loc) · 1.18 KB
/
Simulator.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
from Table import Table, GameType
from GameState import GameState
from Player import Player
from RandomPlayer import RandomPlayer
import logging
from typing import List, TypeVar
import pymongo
# @todo: This isn't working right. Not sure if its my IDE or something else.
P = TypeVar('P', Player, RandomPlayer)
class Simulator(object):
def __init__(self, game_type: GameType, num_games: int, player_strategy: P):
self.game_type = game_type
self.num_games = num_games
# @todo Need to make this some sort of specifiable list but not supported by the table.
self.player_strategy = player_strategy
self.game_count = 0
def run_game(self, game_id: int):
# Play one full game.
t = Table(self.player_strategy, game_id, self.game_type)
while True:
if t.game_state.get_state() == GameState.TRICK_START:
t.print_player_hands()
t.step_game()
if t.game_state.get_state() == GameState.GAME_START:
break
self.game_count += 1
def run(self):
for x in range(0, self.num_games):
print("Simulating Game: {}".format(x))
self.run_game(x)