Exemplo n.º 1
0
 def play_game(self):
     from strategy import Strategy
     s = Strategy()
     move_number = 0
     while not self.battlefield.game_over:
         x, y = s.get_action(self.battlefield.field_for_enemy)
         self.battlefield.attack_battlefield(x, y)
         move_number += 1
     print(self.battlefield.field_for_enemy)
     print('Game ended in %s moves' % move_number)
Exemplo n.º 2
0
    def play_one_hand(self):
        self.message = self.receive_string()
        self.gamestate = GameState(self.message)

        while not self.gamestate.finished:
            if self.gamestate.is_my_turn():
                # gamestate -> rules
                strategy = Strategy(self.gamestate)
                # rules -> strategy

                # strategy -> action

                # original message + action -> response
                # action = self.choose_random_action()
                response_string = self.generate_response(strategy.get_action())

                # send
                self.send_string(response_string)

            # else not my turn
            # do nothing
            # receive next message and update gamestate
            self.message = self.receive_string()
            self.gamestate = GameState(self.message)