Example #1
0
    def do_turn(self, turn_data: TurnData) -> Action:
        state = turn_data
        agent_x, agent_y = state.agent_data[0].position
        if not self.sequence0 and not self.sequence1:
            problem = Graph(state.map)
            if not state.agent_data[0].carrying:
                problem.agent = f'{agent_x},{agent_y}'
                heuristics = heuristic_list(problem)
                self.sequence0 = graph_search(problem, heuristics)
            else:
                problem.agent = f'{agent_x},{agent_y}'
                problem.final = True
                heuristics = heuristic_list(problem)
                self.sequence1 = graph_search(problem, heuristics)

        if self.sequence0:
            return self.sequence0.pop()
        elif self.sequence1:
            return self.sequence1.pop()
Example #2
0
 def do_turn(self, turn_data) -> Action:
     state = turn_data
     # state = self.updateState(state, turn_data)
     if not self.sequence0 and not self.sequence1:
         problem = Graph(state.map)
         if not state.agent_data[0].carrying:
             agentx, agenty = turn_data.agent_data[0].position
             problem.agent = f'{agentx},{agenty}'
             self.sequence0 = search(problem)
         else:
             problem.final = True
             agentx, agenty = turn_data.agent_data[0].position
             problem.agent = f'{agentx},{agenty}'
             self.sequence1 = search(problem)
         # if not self.sequence:
         # return None
     if self.sequence0:
         return self.sequence0.pop()
     elif self.sequence1:
         return self.sequence1.pop()