From 1963068dd6aaf644a2a7c013c45362e9fffa1a12 Mon Sep 17 00:00:00 2001 From: Anna Nowak Date: Mon, 13 May 2019 09:09:48 +0200 Subject: [PATCH] Naprawiono bug z DFS --- Traversal/DFS.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) 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")