def get_move_list_for_biggest_play_from(game_state: BotGameState, strategy: Strategy, origin): """ Get a list of moves corresponding to the largest play from the specified origin point. :param game_state: the BotGameState for the current turn. :param strategy: The Strategy to use to determine the valid move to return. :param origin: The number to start on, or an iterable containing start numbers. All paths will start with one of those number. :return:A list of moves corresponding to the largest play :rtype: List(BotMove) """ try: play = strategy.choose_play(game_state, game_state.get_biggest_plays_from(origin)) moves = [] used_trains = [] # Loop through the sorted paths, so that any path which demands satisfaction is last for path in sorted(play.paths, key=attrgetter('demands_satisfaction')): if path.size > 0: train = strategy.choose_train_for_path(game_state, path, used_trains) used_trains.append(train) moves.extend([BotMove(make_domino_from_edge(edge), train) for edge in path.edge_list]) except AttributeError as e: print(e) moves = BaseBot.get_move_list_for_longest_paths_from(game_state, strategy, origin) return moves
def get_move_list_for_longest_paths_from(game_state: BotGameState, strategy: Strategy, origin): """ Get a list of moves corresponding to the longest path from the specified origin point. :param game_state: the BotGameState for the current turn. :param strategy: The Strategy to use to determine the valid move to return. :param origin: The number to start on, or an iterable containing start numbers. All paths will start with one of those number. :return: A list of moves corresponding to the longest path :rtype: List(BotMove) """ path, train = strategy.choose_path_and_train(game_state, game_state.get_longest_paths_from(origin), game_state.playable_trains) return [BotMove(make_domino_from_edge(edge), train) for edge in path.edge_list]