Zmieniono DFS na rekurencyjny
This commit is contained in:
parent
7cd150fa90
commit
b8aaf2d78e
@ -1,9 +1,8 @@
|
||||
from utilities import movement,check_moves
|
||||
from DataModels.House import House
|
||||
from DataModels.Container import Container
|
||||
stack = []
|
||||
def visit_cell(grid, available_movement, gc_moveset, depth=0):
|
||||
global stack
|
||||
|
||||
def DFS(grid, available_movement, gc_moveset, depth=0):
|
||||
possible_goals = []
|
||||
a = gc_moveset[-1][0]
|
||||
b = gc_moveset[-1][1]
|
||||
@ -34,13 +33,6 @@ def visit_cell(grid, available_movement, gc_moveset, depth=0):
|
||||
available_movement_next = check_moves(grid, x_next,y_next,direction)
|
||||
gc_moveset_next = gc_moveset.copy()
|
||||
gc_moveset_next.append([x_next,y_next])
|
||||
stack.append([grid, available_movement_next, gc_moveset_next, depth+1])
|
||||
|
||||
def DFS(grid, available_movement, gc_moveset, depth=0):
|
||||
global stack
|
||||
stack.append([grid, available_movement, gc_moveset, 0])
|
||||
while not len(stack)==0:
|
||||
state = stack.pop()
|
||||
result = visit_cell(state[0], state[1], state[2],state[3])
|
||||
result = DFS(grid, available_movement_next, gc_moveset_next, depth+1)
|
||||
if result!= None:
|
||||
return result
|
||||
|
Loading…
Reference in New Issue
Block a user