瀏覽代碼

Fix duplicates explored tiles

Was causing BFS to never finish
DricomDragon 5 年之前
父節點
當前提交
d1341ddc3d
共有 1 個文件被更改,包括 2 次插入4 次删除
  1. 2 4
      main.cc

+ 2 - 4
main.cc

@@ -201,13 +201,12 @@ class World
 
 					if (!explored[neighbour]) {
 						open.push(neighbour);
+						explored[neighbour] = true;
 						previous[neighbour] = current;
 					}
 				}
 
 				// Current tile is now processed
-				explored[current] = true;
-
 				discovered.push_back(current);
 
 				// Stop if target found
@@ -274,13 +273,12 @@ class World
 
 					if (!explored[neighbour]) {
 						open.push(neighbour);
+						explored[neighbour] = true;
 						previous[neighbour] = current;
 					}
 				}
 
 				// Current tile is now processed
-				explored[current] = true;
-
 				discovered.push_back(current);
 
 				// Stop if target found