naprawiono bug z DFS
This commit is contained in:
parent
a605f7a87e
commit
36b8bf702a
@ -50,6 +50,7 @@ class GC(Cell):
|
|||||||
house,[x,y],result = DFS(enviromnent,avalible_moves,[[x,y]],House)
|
house,[x,y],result = DFS(enviromnent,avalible_moves,[[x,y]],House)
|
||||||
elif mode == "BFS":
|
elif mode == "BFS":
|
||||||
house,[x,y],result = BFS(enviromnent,avalible_moves,[[x,y]],House)
|
house,[x,y],result = BFS(enviromnent,avalible_moves,[[x,y]],House)
|
||||||
|
result = result[1::]
|
||||||
self.moves.extend(result)
|
self.moves.extend(result)
|
||||||
element_list.append(house)
|
element_list.append(house)
|
||||||
|
|
||||||
|
@ -40,7 +40,6 @@ def BFS(grid, available_movement, gc_moveset, mode):
|
|||||||
x,y = gc_moveset_state[-1]
|
x,y = gc_moveset_state[-1]
|
||||||
if(object_in_area):
|
if(object_in_area):
|
||||||
gc_moveset_state.append("pick_garbage")
|
gc_moveset_state.append("pick_garbage")
|
||||||
gc_moveset_state=gc_moveset_state[1::]
|
|
||||||
return (cell,[x,y], gc_moveset_state)
|
return (cell,[x,y], gc_moveset_state)
|
||||||
|
|
||||||
for direction in avalible_movement_state:
|
for direction in avalible_movement_state:
|
||||||
|
@ -25,7 +25,7 @@ def DFS(grid, available_movement, gc_moveset, mode,depth=0):
|
|||||||
x,y = gc_moveset[-1]
|
x,y = gc_moveset[-1]
|
||||||
if(object_in_area):
|
if(object_in_area):
|
||||||
gc_moveset.append("pick_garbage")
|
gc_moveset.append("pick_garbage")
|
||||||
return (cell,[x,y], gc_moveset)
|
return [cell,[x,y], gc_moveset]
|
||||||
|
|
||||||
if len(available_movement) == 0 or depth>30:
|
if len(available_movement) == 0 or depth>30:
|
||||||
return
|
return
|
||||||
@ -35,6 +35,5 @@ def DFS(grid, available_movement, gc_moveset, mode,depth=0):
|
|||||||
gc_moveset_next = gc_moveset.copy()
|
gc_moveset_next = gc_moveset.copy()
|
||||||
gc_moveset_next.append([x_next,y_next])
|
gc_moveset_next.append([x_next,y_next])
|
||||||
result = DFS(grid, available_movement_next, gc_moveset_next,mode, depth+1)
|
result = DFS(grid, available_movement_next, gc_moveset_next,mode, depth+1)
|
||||||
result[2]=result[2][1::]
|
|
||||||
if result!= None:
|
if result!= None:
|
||||||
return result
|
return result
|
||||||
|
Loading…
Reference in New Issue
Block a user