
duda con funcion que se me cicla y no logro arreglarlo
Publicado por laura (2 intervenciones) el 21/10/2015 11:23:12
Hola, tengo esta funcion q implementa el algoritmo A* para resolver el puzzle 8, lo que pasa es q se me hace un ciclo infinito y no he podido, encontrar donde esta el problema.. por favor si alguien pudiera ayudarme..
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
def Astar(heur):
fn=0
global g
g=1
abierta=[start]
cerrada[:]=[]
costo=0
while len(abierta)!=0:
for M in abierta:
X= abierta.pop(0)
cerrada.append(X)
if X==end:
if heur==1:
print " "
print "'HEURISTICA 1:'"
print " "
print cerrada, "con costo", costo, "y profundidad",g
print "__________________________________________ "
if heur==2:
print " "
print "'HEURISTICA 2:'"
print " "
print cerrada, "con costo", costo, "y profundidad",g
print "__________________________________________"
if heur==3:
print " "
print "'HEURISTICA 3:'"
print " "
print cerrada, "con costo", costo, "y profundidad",g
print "__________________________________________ "
break
global hijos
busc0(X)
mov=[]
posmov(col,fil,mov)
intercambio(col,fil,mov,X)
result=[]
for n in hijos:
if heur==1:
fn=heur1(n,end,g)
if heur==2:
fn=heur2(n,end,g)
if heur==3:
fn=heur3(n,end)
result.append(fn)
minimo=min(result)
costo=costo+minimo
m=result.index(minimo)
S=hijos[m]
hijos=[]
g+=1
for i in abierta:
if i==S:
abierta.remove(i)
for i in cerrada:
if i==S:
cerrada.remove(i)
abierta.append(S)
Astar(1)
Valora esta pregunta


0