Explorar el Código

Remove origin and target from path and discovered

DricomDragon hace 5 años
padre
commit
1dc13e7001
Se han modificado 1 ficheros con 6 adiciones y 0 borrados
  1. 6 0
      main.cc

+ 6 - 0
main.cc

@@ -213,12 +213,18 @@ class World
 
 			} while (!targetIsReached && !open.empty());
 
+			// Remove origin and target
+			discovered.pop_front();
+			discovered.pop_back();
+
 			// Build path
 			if (targetIsReached) {
 				do {
 					path.push_back(current);
 					current = previous[current];
 				} while (current != origin);
+
+				path.pop_front();
 			}
 
 			return targetIsReached;