def test_get_actions_randomly(self): not_expected = [] for action in list(Action): not_expected.append(action) result = Action.get_actions(True) while result == not_expected: result = Action.get_actions(True) self.assertNotEqual(not_expected, result)
def create_all_next_surviving_actions(self, game: Game) -> List[Action]: """Calculates not only one but all actions that will let the player survive for the next rounds. Args: game: The current state of the game. Returns: A list of actions which will let the player survive for the next rounds. """ root = SearchTreeRoot(game.copy()) player_ids_to_watch = game.get_other_player_ids( self.player, self.__distance_to_check, True) combinations = Action.get_combinations(len(player_ids_to_watch)) search_tree_actions = [] for action in Action.get_actions(): if root.calculate_action(self.player, player_ids_to_watch, combinations, self.__depth, self._turn_ctr, True, [action], self._max_speed, True) is not None: search_tree_actions.append(action) return search_tree_actions
def test_get_actions_in_order(self): expected = [] for action in list(Action): expected.append(action) result = Action.get_actions() self.assertEqual(expected, result)
def __get_actions(root: bool, first_actions: List[Action], randomize: bool) -> List[Action]: if root and first_actions is not None and len(first_actions) >= 1: return first_actions return Action.get_actions(randomize)