From 1d22c53e6f73f34c299b5c9cb29288346d48aea6 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sun, 12 Jan 2025 17:51:03 +0200 Subject: hw(AI/1): Add timer on any argument --- Year 4/Artificial Intelligence/hw01/main.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Year 4/Artificial Intelligence/hw01/main.cpp b/Year 4/Artificial Intelligence/hw01/main.cpp index 87e6167..17b568b 100644 --- a/Year 4/Artificial Intelligence/hw01/main.cpp +++ b/Year 4/Artificial Intelligence/hw01/main.cpp @@ -5,10 +5,12 @@ #include #include #include +#include // #include "graph.h" using namespace std; +using namespace chrono; int I, N = 0; @@ -171,7 +173,7 @@ bool solvable(Node* root) { } } -int main() { +int main(int argc, char* argv[]) { /* Input */ cin >> N >> I; if (I == -1) { I = N; } @@ -200,11 +202,15 @@ int main() { path.push_back(root); /* IDA* */ + auto startTime = system_clock::now(); + int bound = 3; while(bound != SOLVED) { bound = dfs(path, bound); } + auto endTime = system_clock::now(); + /* Output */ cout << (path.size() - 1) << endl; for (int i = 1; i < path.size(); i++) { @@ -212,4 +218,9 @@ int main() { delete path[i]; } delete root; + + if (argc > 1) { + auto millis = duration_cast(endTime - startTime).count(); + std::cout << "Took: " << millis / 1000.0 << "s" << std::endl; + } } -- cgit v1.3.1-26-gb76a