def codalab_run(run_id): if run_id == 0: ## H shape map env = environment.DiscreteSquareMapEnv(preset=5) label_data = label(env, end=(2, 5)) desc_agent(env, label_data, mode="back") stats = { "turn": env.agent_turns, "dist": env.agent_distance, "notes": "Backward" } return stats if run_id == 1: ## H shape map env = environment.DiscreteSquareMapEnv(preset=5) label_data = label(env, end=(1, 4)) desc_agent(env, label_data, mode="astar") stats = { "turn": env.agent_turns, "dist": env.agent_distance, "notes": "A*" } return stats if run_id == 2: ## H shape map env = environment.DiscreteSquareMapEnv(preset=101) label_data = label(env, end=(5, 5)) desc_agent(env, label_data, mode="back") stats = { "turn": env.agent_turns, "dist": env.agent_distance, "notes": "Backward" } return stats if run_id == 3: ## H shape map env = environment.DiscreteSquareMapEnv(preset=101) label_data = label(env, end=(5, 5)) desc_agent(env, label_data, mode="astar") stats = { "turn": env.agent_turns, "dist": env.agent_distance, "notes": "A*" } return stats
def codalab_run(run_id): if run_id == 0: ## H shape map test_env = environment.DiscreteSquareMapEnv(preset=5) astar_test(test_env) stats = { "turn": test_env.agent_turns, "dist": test_env.agent_distance, "notes": "Pure Astar" } return stats if run_id == 1: ## H shape map test_env = environment.DiscreteSquareMapEnv(preset=5) astar_test(test_env) stats = { "turn": test_env.agent_turns, "dist": test_env.agent_distance, "notes": "Pure Astar" } return stats if run_id == 2: ## H shape map test_env = environment.DiscreteSquareMapEnv(preset=101) astar_test(test_env) stats = { "turn": test_env.agent_turns, "dist": test_env.agent_distance, "notes": "Pure Astar" } return stats if run_id == 3: ## H shape map test_env = environment.DiscreteSquareMapEnv(preset=101) astar_test(test_env) stats = { "turn": test_env.agent_turns, "dist": test_env.agent_distance, "notes": "Pure Astar" } return stats
def codalab_run(run_id): random.seed(0) if run_id == 0: ## H shape map env = environment.DiscreteSquareMapEnv(preset=5) random_agent(env) notes = "" if env.num_unvisited_nodes() > 0: notes = "agent trapped" stats = { "turn": env.agent_turns, "dist": env.agent_distance, "notes": notes } return stats if run_id == 1: ## H shape map env = environment.DiscreteSquareMapEnv(preset=101) random_agent(env) notes = "" if env.num_unvisited_nodes() > 0: notes = "agent trapped" stats = { "turn": env.agent_turns, "dist": env.agent_distance, "notes": notes } return stats
def main(): # env = DiscreteSquareMapEnv(map_dim=(6, 6), block_area=(((1, 2), (3, 3)), ((4, 4), (5, 5)))) env = environment.DiscreteSquareMapEnv(preset=5) print(env.map.data) label_data = label(env, end=(3, 3)) # print(label_data) # # desc_agent(env, label_data, mode="astar") # # desc_agent(env, label_data) env.plot_path(label_data=None)
def __init__(self): self.env = environment.DiscreteSquareMapEnv()
def __init__(self, map_dim=(3, 3), block_area=None, start=(1, 1)): self.env = environment.DiscreteSquareMapEnv(map_dim, block_area, start) self.lmapsize = 3
# min_size = 5 # max_size = 25 # obs_corners_x = np.random.randint(0,width,num_obs) # obs_corners_y = np.random.randint(0,height,num_obs) # obs_lower_corners = np.vstack([obs_corners_x,obs_corners_y]).T # obs_sizes = np.random.randint(min_size,max_size,(num_obs,2)) # obs_upper_corners = obs_lower_corners + obs_sizes # obstacles = zip(obs_lower_corners,obs_upper_corners) # occupancy = DetOccupancyGrid2D(width, height, obstacles) # x_init = tuple(np.random.randint(0,width-2,2).tolist()) # x_goal = tuple(np.random.randint(0,height-2,2).tolist()) # while not (occupancy.is_free(x_init) and occupancy.is_free(x_goal)): # x_init = tuple(np.random.randint(0,width-2,2).tolist()) # x_goal = tuple(np.random.randint(0,height-2,2).tolist()) test_env = env.DiscreteSquareMapEnv(preset=5) # test_env = env.DiscreteSquareMapEnv(map_dim=(5, 5), block_area=((None)) # test_env = env.DiscreteSquareMapEnv(map_dim=(5, 5), block_area=(((1, 2), (3, 2)),)) width = test_env.map.height height = test_env.map.width obstacles = list(test_env.block_area) occupancy = DetOccupancyGrid2D(width, height, obstacles) action = test_env.available_actions()[0] iteration = 0 # action list act_list = [] # when agent visited all nearby cells, # record current location and new unvisitied location in this list. jump_node_list = [] # keep looping until all cells visieted while test_env.num_unvisited_nodes() != 0: