def generate_state_space(self, search_file=None):
     """c
     """
     super(DotAgent, self).generate_state_space()
     self.dot_coordinates = set(self.dot_coordinates)
     # Generate adjacency matrix of spaces with dots in them.
     if self.check_loops:
         self.look_for_loops()
     base_space = self.base_state_space
     dot_state_space = {}
     agent = Agent(search_file, state_space=base_space)
     dot_coordinates = list(self.dot_coordinates)
     for x in range(len(dot_coordinates)):
         coordx = dot_coordinates[x]
         dot_state_space[coordx] = {}
         for y in range(len(dot_coordinates)):
             coordy = dot_coordinates[y]
             # No need to check if the coordinates are equal. Basic
             # pathfinding module will just check the while loop
             # condition, and it will function as an if condition.
             ######################################################
             # Get optimal path cost between points coordx and
             # coordy
             start = copy.copy(base_space[coordx])
             goal = copy.copy(base_space[coordy])
             agent.goal_state = goal
             agent.start_state = start
             agent.search("a*", new_state_space=False)
             solution = agent.solution_node
             dot_state_space[coordx][coordy] = solution
     # Overwrite base state space with adjacency matrix.
     # States should now be generated on the fly as needed based
     # off of the adjacency matrix.
     self.state_space = dot_state_space
Пример #2
0
def main():
    """c
    """
    search_files = [
        'designed_map_1.txt',
        'designed_map_2.txt',
    ]
    search_types = [
        'gbfs',
        'a*'
    ]

    for search_file in search_files:
        agent = Agent(search_file)
        for search_type in search_types:
            agent.search(search_type, do_not_print=False)