from utilities import movement,check_moves from DataModels.House import House def DFS(grid, avaliable_movement, gc_moveset,goal): print("Moveset: "+str(gc_moveset)) possible_goals = [] a = gc_moveset[-1][0] b = gc_moveset[-1][1] possible_goals.append([a+1,b]) possible_goals.append([a-1,b]) possible_goals.append([a,b+1]) possible_goals.append([a,b-1]) house_in_area = False for location in possible_goals: try: if(type(grid[location[0]][location[1]]) == House): house_in_area = True break except: continue print(str(house_in_area) + " possible goals: " + str(possible_goals) + " gc_moveset: " + str(gc_moveset[-1])) if(house_in_area or len(avaliable_movement) == 0): print("Do zwrocenia: ",gc_moveset) return gc_moveset x,y = gc_moveset[-1] for direction in avaliable_movement: x_next, y_next = movement(grid,x,y)[0][direction] avaliable_movement_next = check_moves(grid, x_next,y_next,direction) gc_moveset_next = gc_moveset.copy() gc_moveset_next.append([x_next,y_next]) return DFS(grid, avaliable_movement_next, gc_moveset_next,goal)