def generic_solver_multi(maze_num): maze_map = mazes[maze_num] selected_type = request.args.get('search_type') # change string to enum selected_type = search_type.A_Star if selected_type == "a_star" else selected_type selected_type = search_type.DFS if selected_type == "dfs" else selected_type selected_type = search_type.BFS if selected_type == "bfs" else selected_type selected_type = search_type.GFS if selected_type == "gfs" else selected_type s = search(selected_type, maze_map) targets_dict = s.get_path() distance = s.get_cost() targets_ordered = list(targets_dict.keys()) path = multi_point_path(targets_dict) # points = path_id_to_points(maze_map, path) for k in targets_dict.keys(): path_ids = targets_dict[k] path = [maze_map.graph.nodes[id_] for id_ in path_ids] points = path_to_points(path) targets_dict[k] = points return json.dumps({"points": targets_dict, "order": targets_ordered, "cost": distance}, cls=EnhancedJSONEncoder)
def search_endpoint(): query = request.args.get("query") medium = request.args.get("medium") results = search(query, medium) return jsonify(results)
def home(): if request.method == 'GET': return render_template('index.html', ID = "") else: search_term = request.form['lyric'] outputfilename = search.setup(search_term) client_id, client_secret, client_access_token = search.load_credentials() return render_template('index.html', ID= search.search(request.form['lyric'],rake.do(search_term),outputfilename,client_access_token))#, hi=translator.prep(search.setup(search_term)))
def search_key(): if request.method == 'GET': key = request.args.get('key_txt') if key: result = search(key) if result: return render_template('index_upload.html', result=result) return render_template('index_upload.html')
def main(): mode = input( 'Welcome to Gresynonyms, pls type your commands:\n-s: search for words or explainations\n-i: input new words pair\n' ) if mode == '-s': search.search() elif mode == '-q': memorize.main() # elif '--rw' in mode: elif mode == '-i': input_continue = "y" while input_continue != "N": save_words.input_pairs() input_continue = input("continue input? y/N: ") elif mode == '--help': print('-s search /n -q quiz /n --rw random word /n -w write new pairs') else: print('invalid inpt, pls ')
async def play(self, ctx, *song): await self.join(ctx) server = ctx.message.server voice_client = self.bot.voice_client_in(server) player = await voice_client.create_ytdl_player( search(song), after=lambda: self.check_queue(ctx)) if self.players.get(server.id) is None: self.players[server.id] = player player.start() await self.bot.say("now playing " + player.title) else: await self.queue(server.id, player)
def _traverse(self, curr_node, LCCN): if not curr_node: return srh = search() if srh.contains(curr_node.getLCCN(), LCCN): children = curr_node.getChildren() if children: for child in children: ret_node = self._traverse(child, LCCN) if ret_node: return ret_node return curr_node
def epander_solver(maze_num): maze_map = mazes[maze_num] selected_type = request.args.get('search_type') # change string to enum selected_type = search_type.A_Star if selected_type == "a_star" else selected_type selected_type = search_type.DFS if selected_type == "dfs" else selected_type selected_type = search_type.BFS if selected_type == "bfs" else selected_type selected_type = search_type.GFS if selected_type == "gfs" else selected_type s = search(selected_type, maze_map) expantion = s.get_expansion() distance = s.get_cost() # points = path_id_to_points(maze_map, path) # print(path) # distance = path_to_distance(path) return json.dumps({"expantion": expantion, "cost": distance}, cls=EnhancedJSONEncoder)
def generic_solver_single(maze_num): maze_map = mazes[maze_num] selected_type = request.args.get('search_type') # change string to enum selected_type = search_type.A_Star if selected_type == "a_star" else selected_type selected_type = search_type.DFS if selected_type == "dfs" else selected_type selected_type = search_type.BFS if selected_type == "bfs" else selected_type selected_type = search_type.GFS if selected_type == "gfs" else selected_type s = search(selected_type, maze_map) path = list(s.get_path().values())[0] distance = s.get_cost() points = path_id_to_points(maze_map, path) # print(path) # distance = path_to_distance(path) return json.dumps({"points": points, "cost": distance}, cls=EnhancedJSONEncoder)
'mediumSearch.txt', 'smallSearch.txt', 'tinySearch.txt' ] # NOTE testing common search logic for i in search_type: for j in range(7): if j > 2 and i == search_type.DFS: break maze_name = mazes[j] maze_map = Maze_map(f'Maze/{maze_name}') search_type_name = i.name # print("Testing...") print('search type is: ', i) s = search(i, maze_map) path = s.get_path() _path_copy = deepcopy(path) path_nodes_ids = multi_point_path(_path_copy) try: points = path_id_to_points(maze_map, path_nodes_ids) except: points = [0] # print(f"path saved in sol/{search_type_name}/{mazes[j]}") cost = s.get_cost() # cost = 0 print(cost) print(len(points) - 1) # print(cost == len(points))