diff --git a/Traversal/DFS.py b/Traversal/DFS.py index 2efa0fd..0393ec3 100644 --- a/Traversal/DFS.py +++ b/Traversal/DFS.py @@ -12,14 +12,15 @@ def DFS(grid, available_movement, gc_moveset, depth=0): possible_goals.append([a,b-1]) house_in_area = False for location in possible_goals: - try: - cell = grid[location[0]][location[1]] - if(type(cell) == House and cell.container.is_full and cell.unvisited): - cell.unvisited = False - house_in_area = True - break - except: - continue + if location[0]>=0 and location[1]>=0: + try: + cell = grid[location[0]][location[1]] + if(type(cell) == House and cell.container.is_full and cell.unvisited): + cell.unvisited = False + house_in_area = True + break + except: + continue if(house_in_area): xy = gc_moveset[-1] gc_moveset.append("pick_garbage")