print duration

This commit is contained in:
Maximilian Keßler 2023-08-12 23:13:16 +02:00
parent 78a703434d
commit 62bf71a2f2
Signed by: max
GPG key ID: BCC5A619923C0BA5

View file

@ -1,6 +1,7 @@
#include <iostream> #include <iostream>
#include <vector> #include <vector>
#include <variant> #include <variant>
#include <chrono>
#include "game_state.h" #include "game_state.h"
#include "download.h" #include "download.h"
@ -19,20 +20,19 @@ namespace Hanabi {
return; 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 res = game->evaluate_state();
auto end = std::chrono::high_resolution_clock::now();
std::cout.precision(10); std::cout.precision(10);
std::cout << std::endl; std::cout << std::endl;
std::cout << "Probability with optimal play: " << res << std::endl; std::cout << "Probability with optimal play: " << res << " ~ " << std::setprecision(5) << boost::rational_cast<double>(res) * 100 << "%" << std::endl;
std::cout << "Enumerated " << game->enumerated_states() << " states" << std::endl; std::cout << "Took " << std::chrono::duration_cast<std::chrono::milliseconds>(end - start) << "." << std::endl;
std::cout << "Visited " << game->position_tablebase().size() << " unique game states. " << std::endl; std::cout << "Visited " << game->enumerated_states() << " states." << std::endl;
unsigned long biggest_key = 0; std::cout << "Enumerated " << game->position_tablebase().size() << " unique game states. " << std::endl;
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 << 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<HanabiStateIF>(game.release()); auto game_shared = std::shared_ptr<HanabiStateIF>(game.release());
auto states = game_shared->possible_next_states(0, false); auto states = game_shared->possible_next_states(0, false);