for json_ped in json_data: ped_list.append(Pedestrian(json_ped)) return ped_list def isAllReachTarget(ped_list, target_area): for ped in ped_list: if not ped.pos in target_area: return False return True def savePed(ped_list, time): log_msg = "Time " + str(time) + "----\n" for ped in ped_list: log_msg = log_msg + str(ped) + "\n" log.info(log_msg) if __name__ == "__main__": map_info = Map("data/large_basic_map.txt") ped_list = loadPedestrians("data/three_ped.json") time_tick = config.default_time_tick tick_count = 0 experiment = Experiment(map_info) while not isAllReachTarget(ped_list, map_info.getTargetArea()): if tick_count % 1 == 0: print("Tick", tick_count) savePed(ped_list, experiment.time) experiment.tick(ped_list, time_tick) tick_count = tick_count + 1 savePed(ped_list, experiment.time)
else: open_list.append(neigh) self.G_tab[neigh[0]][neigh[1]] = neigh_G self.father_tab[neigh[0]][neigh[1]] = pos if neigh in self.to_area: not_found = False end_pos = neigh break # for neigh in around_list: # while not_found: if not_found: return None route = [end_pos] now_pos = end_pos while now_pos != from_pos: now_pos = self.father_tab[now_pos[0]][now_pos[1]] route.append(now_pos) route.reverse() return route if __name__ == "__main__": map_info = Map("data/basic_map.txt") solver = AStarSolver(map_info, map_info.getTargetArea()) one = (3, 1) one_res = solver.solve(one) print(one, ": ", one_res)