def main(): """ Displays maps and solutions for task 1 and task 2 """ tasks = [1, 2] for task in tasks: map_obj = Map.Map_Obj(task=task) start_position = map_obj.get_start_pos() goal_position = map_obj.get_goal_pos() int_map, str_map = map_obj.get_maps() map_obj.show_map() # Show map with start and goal path = a.best_first_search(map_obj, a.manhattan_distance, a.cost_function, False) print("Starting position: ", start_position) print("Goal position: ", goal_position) try: a.draw_path(map_obj, path) print("Drawing path...") except TypeError: print("Path does not exist :( ") map_obj.show_map() # Show map with path
async def pathfind(context): await context.send('Please send your board:') board = await client.wait_for('message', check=lambda m: m.author == context.author, timeout=6000) board = board.content.strip('`"\' \t\n') try: gif = astar.draw_path(board) except Exception as e: await context.send(str(e)) else: file = File(gif, filename='pathfinding.gif') await context.send('Path:', file=file)
if v.id == ipt: vehicle = v print(vehicle) if vehicle.log != []: path = [] for trip in vehicle.log: path += trip["path"] sa = so = float("inf") ba = bo = -float("inf") for lat, lon in path: sa = min(lat, sa) so = min(lon, so) ba = max(lat, ba) bo = max(lon, bo) draw_graph(G, bounds=((sa, so), (ba, bo))) draw_path(path) plt.show() break elif ipt == "t": ipt = input(f"Enter a trip number (0-{total_trips-1}): ").lower() try: ipt = int(ipt) except: print("Could't convert to int") continue for t in range(total_trips): if t == ipt: trip = trips[t] print(trip) break elif ipt == "s":