Example #1
0
 def __make_node(self, state: State, env_conf: EnvironmentConfiguration):
     name = state.get_current_vertex_name()
     vertex = env_conf.get_vertexes()[name]
     vertex.set_state(state)
     vertex.set_cost(
         len(state.get_required_vertexes()) -
         sum(state.get_required_vertexes().values()))
     return vertex
    def cut_off_utility_eval(state: State, is_max_player: bool, vertexes_dict: Dict[str, Vertex]) -> Tuple[int, int]:
        left_vertexes_to_visit = [state_name for state_name in state.get_required_vertexes().keys()
                                  if not state.get_required_vertexes()[state_name]]
        left_people_to_visit = 0
        for left_vertex_to_visit in left_vertexes_to_visit:
            left_people_to_visit += vertexes_dict[left_vertex_to_visit].get_people_num()

        max_player_score, min_player_score = state.get_scores_of_agents()
        if is_max_player:
            max_player_score += left_people_to_visit
        else:
            min_player_score += left_people_to_visit
        print("cut_off= ", str((max_player_score, min_player_score)))
        return max_player_score, min_player_score
Example #3
0
 def calc_estimation_from_goal(self, current_state: State,
                               goal_state: State):
     vertex_to_is_visited = current_state.get_required_vertexes()
     counter = 0
     for _, was_visited in vertex_to_is_visited.items():
         if not was_visited:
             counter += 1
     return counter
Example #4
0
 def get_state_traveled_vertexes(state: State) -> List[str]:
     required_vertexes_dict = state.get_required_vertexes()
     return [vertex_name for vertex_name in required_vertexes_dict.keys()
             if required_vertexes_dict[vertex_name]]
 def goal_test(self, problem: Tuple[State, State, EnvironmentConfiguration],
               current_state: State):
     _, goal_state, _ = problem
     return goal_state.get_required_vertexes(
     ) == current_state.get_required_vertexes()
 def goal_test(self, problem: Tuple[State, State, EnvironmentConfiguration], current_state: State):
     if self._expansions_num >= self.__limit:
         self._was_terminate = True
     _, goal_state, _ = problem
     return goal_state.get_required_vertexes() == current_state.get_required_vertexes()
 def are_no_more_people(state: State):
     has_unvisited_state = False in state.get_required_vertexes().values()
     return not has_unvisited_state