def test_hard_bot_time(self): p1_name = "HAL-9000" p2_name = "HAL-9001" p1 = player.AIPlayer(p1_name, gameengine.Difficulty.HIGH) p2 = player.AIPlayer(p2_name, gameengine.Difficulty.HIGH) for i in range(self.rounds): g = gameplatform.Game(p1, p2) self.assertEqual("Game Over", g.start_with_timer(10))
def test_medium_bot_time(self): p1_name = "Pumba" p2_name = "Timon" p1 = player.AIPlayer(p1_name, gameengine.Difficulty.MEDIUM) p2 = player.AIPlayer(p2_name, gameengine.Difficulty.MEDIUM) for i in range(self.rounds): g = gameplatform.Game(p1, p2) self.assertEqual("Game Over", g.start_with_timer(10))
def test_easy_bot_time(self): p1_name = "Alfred" p2_name = "Derfla" p1 = player.AIPlayer(p1_name, gameengine.Difficulty.LOW) p2 = player.AIPlayer(p2_name, gameengine.Difficulty.LOW) for i in range(self.rounds): g = gameplatform.Game(p1, p2) self.assertEqual("Game Over", g.start_with_timer(10))
def main(): rounds = 5 p1_name = "Jeff" p2_name = "Dave" p3_name = "Alfred" p4_name = "Pumba" p5_name = "HAL-9000" p1 = player.HumanPlayer(p1_name) p2 = player.HumanPlayer(p2_name) p3 = player.AIPlayer(p3_name, gameengine.Difficulty.LOW) p4 = player.AIPlayer(p4_name, gameengine.Difficulty.MEDIUM) p5 = player.AIPlayer(p5_name, gameengine.Difficulty.HIGH) my_timer = threading.Timer(120.0, mytimer) my_timer.start() run_game(1, p1, p2, p1_name, p2_name) my_timer.cancel()
def HAL_9000_vs_Pumba(rounds): draw_counter = 0 pumba_win_count = 0 hal_win_count = 0 pumba_name = "Pumba" hal_name = "HAL 9000" p3 = player.AIPlayer("Alfred", gameengine.Difficulty.LOW) pumba = player.AIPlayer("Pumba", gameengine.Difficulty.MEDIUM) hal = player.AIPlayer("HAL 9000", gameengine.Difficulty.HIGH) for i in range(rounds): g = gameplatform.Game(pumba, hal) g.start() winner = g.get_winner() if winner: if pumba_name == winner: pumba_win_count += 1 else: hal_win_count += 1 else: draw_count += 1 return hal_win_count, pumba_win_count, draw_counter
def __init__(self, number_of_colors, height, width, game_type, save_images_suffix=False): self.number_of_cells = height * width self.all_colors = np.arange(number_of_colors) self.game_type = game_type self.save_images_suffix = save_images_suffix figure = self.game_type != self.game_types['r_l'] self.game_board = FillerBoard(number_of_colors, height, width, figure=figure) self.turn_count = 0 player_1_starting_cell = (height - 1, 0) if self.game_type == self.game_types['vs_ai']: self.player_1 = player.AIPlayer([player_1_starting_cell], self.game_board) elif self.game_type == self.game_types['r_l']: self.player_1 = player.RLPlayer([player_1_starting_cell], self.game_board) elif self.game_type == self.game_types['human']: self.player_1 = player.HumanPlayer([player_1_starting_cell], self.game_board) elif self.game_type == self.game_types['random']: self.player_1 = player.RandomPlayer([player_1_starting_cell], self.game_board) player_2_starting_cell = (0, width - 1) self.player_2 = player.AIPlayer([player_2_starting_cell], self.game_board)
def start(self): # Start Loop while self._prompt_newgame(): self.log.info('Starting new game') self.board = board.Board(config.board_size) if self.ai_player: self.player = player.AIPlayer(self.board) else: self.player = player.HumanPlayer(self.board) self.gameover = False self.speed = config.speed self.reset_food() self._loop()
def addAIPlayer(self, name, profile, level): """Create an AI player. 'name' is the name of the player to create (string). 'profile' is the the AI profile to use (ai.Profile). 'level' is the difficulty level to use (string). Returns an AI player to use (game.ChessPlayer). """ # Translators: Description of an AI player used in log window. %(name)s is replaced with # the name of the AI player. %(game)s is replaced with the name of the game the AI player # is in. description = _("'%(name)s' in '%(game)s'") % { 'name': name, 'game': self.name } p = player.AIPlayer(self.application, name, profile, level, description) self.__aiPlayers.append(p) self.application.watchAIPlayer(p) return p
def __init__(self, numPlayers, AIPlayers = []): """numPlayers: int AIPlayers: list of tuples: (name, strategy) name: string strategy: tuple: (buyStrategy, actionStrategy) """ startingDeck = ["estate"]*3 + ["copper"]*7 self.players = [] for i in range(numPlayers): self.players.append(player.Player("Player" + str(i), startingDeck)) for i in AIPlayers: name = i[0] strategy = i[1] self.players.append(player.AIPlayer(name, startingDeck, strategy)) self.numPlayers = len(self.players) self.gameDeck = cards.Deck() self.playerToMoveNext = 0