Browse Source

Display discovered tiles

DricomDragon 5 years ago
parent
commit
0196bad292
1 changed files with 7 additions and 3 deletions
  1. 7 3
      main.cc

+ 7 - 3
main.cc

@@ -153,7 +153,7 @@ class World
 		// starting from tile number s0, find a path to tile number t
 		// return true if such a path exists, false otherwise
 		// if it exists the path is given in variable path (hence the reference &)
-		bool dfs(unsigned int s0, unsigned int target, list<unsigned int>& path)
+		bool dfs(unsigned int s0, unsigned int target, list<unsigned int>& path, list<unsigned int>& discovered)
 		{
 			bool r = false;
 
@@ -194,6 +194,8 @@ class World
 				// Current tile is now processed
 				explored[current] = true;
 
+				discovered.push_back(current);
+
 				// Stop if target found
 				r = (current == target);
 
@@ -233,12 +235,14 @@ int main()
 
 	// Find a path with Depth-First Search
 	list<unsigned int> dfsPath;
-	bool exitFound = w.dfs(start, end, dfsPath);
+	list<unsigned int> dfsDiscovered;
+	bool exitFound = w.dfs(start, end, dfsPath, dfsDiscovered);
 
 	// Display DFS
 	cout << endl << "Depth-First Search" << endl;
 
-	w.markAll(dfsPath);
+	w.markAll(dfsDiscovered, DISCOVERED);
+	w.markAll(dfsPath, TRACE);
 	w.markOne(start, ORIGIN);
 	w.markOne(end, TARGET);
 	w.display();