def main(): metodo = raw_input( "Ingrese el metodo de busqueda-- (greedy,depth_first,breadth_first,astar)\n" ) STATE = generarEstado(LABERINTO) problema = rataProblem(STATE) if metodo == "breadth_first": r = breadth_first(problema, graph_search=True, viewer=ConsoleViewer()) if metodo == "greedy": r = greedy(problema, graph_search=True, viewer=ConsoleViewer()) if metodo == "depth_first": r = depth_first(problema, graph_search=True, viewer=ConsoleViewer()) if metodo == "astar": r = astar(problema, graph_search=True, viewer=ConsoleViewer()) print( "=======================================================================\n" ) print "Estado final :", r.state, "\n" print "Path :", r.path(), "\n" l = [x[0] for x in r.path()] print "Acciones tomadas", l, "\n" print "Costo :", r.cost, "\n"
def resolver(metodo_busqueda, posiciones_personas): state = (posicionRobot, hielosRotos, posiciones_personas) if metodo_busqueda == 'astar': visor=BaseViewer() result = astar(RescateSobreHielo(state),graph_search=True, viewer=visor) elif metodo_busqueda =='breadth_first': visor=BaseViewer() result = breadth_first(RescateSobreHielo(state),graph_search=True, viewer=visor) elif metodo_busqueda =='depth_first': visor=BaseViewer() result = depth_first(RescateSobreHielo(state),graph_search=True,viewer=visor) elif metodo_busqueda =='greedy': visor=BaseViewer() result = greedy(RescateSobreHielo(state),graph_search=True,viewer=visor) return result
def resolver(metodo_busqueda, posiciones_personas): state = (posicionRobot, hielosRotos, posiciones_personas) if metodo_busqueda == 'astar': result = astar(RescateSobreHielo(state)) elif metodo_busqueda == 'breadth_first': result = breadth_first(RescateSobreHielo(state)) elif metodo_busqueda == 'depth_first': result = depth_first(RescateSobreHielo(state)) elif metodo_busqueda == 'greedy': result = greedy(RescateSobreHielo(state)) return result
def resolver(metodo_busqueda, franceses, piratas): viewer = None barcos = [] inicial = (tuple(franceses), tuple(piratas)) problem = entrega1(inicial) if metodo_busqueda == "breadth_first": resultado = breadth_first(problem, graph_search=True, viewer=viewer) elif metodo_busqueda == "greedy": resultado = greedy(problem, graph_search=True, viewer=viewer) elif metodo_busqueda == "depth_first": resultado = depth_first(problem, graph_search=True, viewer=viewer) elif metodo_busqueda == "astar": resultado = astar(problem, graph_search=True, viewer=viewer) elif metodo_busqueda == "uniform_cost": resultado = uniform_cost(problem, graph_search=True, viewer=viewer) return resultado
def main(): estado = "{}|0|I|".format("1-3-6-8-12") problema = problemaLinterna(estado) metodo = raw_input("Ingrese el metodo de busqueda-- (greedy,depth_first,breadth_first)\n") if metodo == "breadth_first": p = breadth_first(problema,graph_search=True,viewer=ConsoleViewer()) if metodo == "greedy": p = greedy(problema,graph_search=True,viewer=ConsoleViewer()) if metodo == "depth_first": p = depth_first(problema,graph_search=True,viewer=ConsoleViewer()) print("=======================================================================\n") print "Estado final :",p.state,"\n" print "Path :",p.path(),"\n" l = [x[0] for x in p.path()] print "Acciones tomadas",l,"\n" print "Costo :",p.cost*10,"segundos","\n"
def main(): metodo = raw_input( "Ingrese el metodo de busqueda-- (greedy,depth_first,breadth_first)\n") problema = problemaLaberinto("1") if metodo == "breadth_first": p = breadth_first(problema, graph_search=True, viewer=ConsoleViewer()) if metodo == "greedy": p = greedy(problema, graph_search=True, viewer=ConsoleViewer()) if metodo == "depth_first": p = depth_first(problema, graph_search=True, viewer=ConsoleViewer()) print( "=======================================================================\n" ) print "Estado final :", p.state, "\n" print "Path :", p.path(), "\n" l = [x[0] for x in p.path()] print "Acciones tomadas", l, "\n" print "Costo :", p.cost, "\n"
def resolver(metodo_busqueda, franceses, piratas): initial = createState(franceses, piratas) my_viewer = None #my_viewer=BaseViewer() if metodo_busqueda == 'astar': result = astar(Intelligents_Pirates(initial), graph_search=True, viewer=my_viewer) elif metodo_busqueda == 'breadth_first': result = breadth_first(Intelligents_Pirates(initial), graph_search=True, viewer=my_viewer) elif metodo_busqueda == 'depth_first': result = depth_first(Intelligents_Pirates(initial), graph_search=True, viewer=my_viewer) elif metodo_busqueda == 'greedy': result = greedy(Intelligents_Pirates(initial), graph_search=True, viewer=my_viewer) return result
def resolver(metodo_busqueda, franceses, piratas): viewer = BaseViewer() barcos_piratas = [] for pirata in piratas: barcos_piratas.append((pirata, 0)) initial = (tuple(franceses), tuple(barcos_piratas)) problem = entrega1(initial) if metodo_busqueda == "breadth_first": resultado = breadth_first(problem, graph_search=True, viewer=viewer) elif metodo_busqueda == "greedy": resultado = greedy(problem, graph_search=True, viewer=viewer) elif metodo_busqueda == "depth_first": resultado = depth_first(problem, graph_search=True, viewer=viewer) elif metodo_busqueda == "astar": resultado = astar(problem, graph_search=True, viewer=viewer) elif metodo_busqueda == "uniform_cost": resultado = uniform_cost(problem, graph_search=True, viewer=viewer) return resultado
def main(): jugador = raw_input("Ingrese la posicion del jugador EJ: 0-2\n") enemigo = raw_input("Ingrese la posicion del enemigo EJ: 0-5\n") castillo = raw_input("Ingrese la posicion del castillo EJ: 3-2\n") global longitud longitud = int(raw_input("Ingrese la longitud de la grilla \n")) - 1 metodo = raw_input( "Ingrese el metodo de busqueda-- (greedy,depth_first,breadth_first,astar)\n" ) estado = generar_estados([jugador, enemigo, castillo]) problema = prolemaDota(estado) if metodo == "breadth_first": p = breadth_first(problema, graph_search=True, viewer=ConsoleViewer()) if metodo == "greedy": p = greedy(problema, graph_search=True, viewer=ConsoleViewer()) if metodo == "depth_first": p = depth_first(problema, graph_search=True, viewer=ConsoleViewer()) if metodo == "astar": p = astar(problema, graph_search=True, viewer=ConsoleViewer()) print( "=======================================================================\n" ) print "Estado final :", p.state, "\n" print "Path :", p.path(), "\n" l = [x[0] for x in p.path()] print "Acciones tomadas", l, "\n" print "Costo :", p.cost, "\n"
def test_greedy(self): result = greedy(self.problem) self.assertEquals(result.state, GOAL)