def __init__(self, player, eval_=True, debug=False, collect_stats=False): self.player = int(player) self.eval = eval_ self.debug = debug self.turn_number = 0 self.b = Board(collect_stats=collect_stats) self.inv_b = Board(invert=self.b, collect_stats=collect_stats)
class GameState(object): def __init__(self, player, eval_=True, debug=False, collect_stats=False): self.player = int(player) self.eval = eval_ self.debug = debug self.turn_number = 0 self.b = Board(collect_stats=collect_stats) self.inv_b = Board(invert=self.b, collect_stats=collect_stats) def start(self): if self.player == 1: self._opp_turn() def evaluator_on_off(self, active): """If `active` eval is on, else it's off""" self.eval = active def turn(self, lr, slot, card): print lr if lr == 1: print card print slot else: print slot print card self.turn_number += 1 sys.stdout.flush() if self.eval: try: self.b.turn(lr, slot, card) except Exception, e: # last resort if self.debug: print >> sys.stderr, "-" * 100, e # raise self._opp_turn() if self.debug: print >> sys.stderr, "" print >> sys.stderr, "BOARD:" print >> sys.stderr, self.b print >> sys.stderr, "" sys.stderr.flush()