From 62bf71a2f2b970ef971f71df32932613f1c49f37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Sat, 12 Aug 2023 23:13:16 +0200 Subject: [PATCH] print duration --- src/main.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 75391b6..838137e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include "game_state.h" #include "download.h" @@ -19,20 +20,19 @@ namespace Hanabi { return; } - std::cout << "Analysing state: " << std::endl << *game << std::endl; + std::cout << "Analysing state: " << std::endl << std::endl << *game << std::endl; + auto start = std::chrono::high_resolution_clock::now(); auto res = game->evaluate_state(); + auto end = std::chrono::high_resolution_clock::now(); std::cout.precision(10); std::cout << std::endl; - std::cout << "Probability with optimal play: " << res << std::endl; - std::cout << "Enumerated " << game->enumerated_states() << " states" << std::endl; - std::cout << "Visited " << game->position_tablebase().size() << " unique game states. " << std::endl; - unsigned long biggest_key = 0; - for(const auto& [key, prob] : game->position_tablebase()) { - biggest_key = std::max(biggest_key, key); - } - std::cout << "Biggest key generated is " << biggest_key << std::endl; + std::cout << "Probability with optimal play: " << res << " ~ " << std::setprecision(5) << boost::rational_cast(res) * 100 << "%" << std::endl; + std::cout << "Took " << std::chrono::duration_cast(end - start) << "." << std::endl; + std::cout << "Visited " << game->enumerated_states() << " states." << std::endl; + std::cout << "Enumerated " << game->position_tablebase().size() << " unique game states. " << std::endl; std::cout << std::endl; + std::cout << "Dropping into interactive command line to explore result (type 'help'):" << std::endl; auto game_shared = std::shared_ptr(game.release()); auto states = game_shared->possible_next_states(0, false);