diff --git a/main.cpp b/main.cpp index cba1084..c215395 100644 --- a/main.cpp +++ b/main.cpp @@ -26,6 +26,13 @@ int main(void) { cout << "Who plays [" << HUMAN << "/" << BOT << "] : "; string player; cin >> player; + bool learn = 0; + if(player == HUMAN) { + cout << "Do you want to know what bot learns [y/n] : "; + string reply; cin >> reply; + learn = (reply == "y"); + } + string gen = RANDOM; if(player == BOT) { cout << "Who generates the sequence [" << HUMAN << "/" << RANDOM << "]: "; @@ -78,6 +85,10 @@ int main(void) { response = validate(sequence, guess); cout << format_response(response); + if(learn) { + bot.learn(guess, response); + bot.print(); + } } history.push_back(guess); diff --git a/solver.hpp b/solver.hpp index 28cd697..a3327bf 100644 --- a/solver.hpp +++ b/solver.hpp @@ -1,7 +1,9 @@ #pragma once #include +#include using std::vector; +using std::cout; struct Game { int N, M; @@ -27,6 +29,19 @@ struct Game { for(int n = 0; n < N; n++) possible[n][col] = 0; } + + void print() { + cout << " "; + for(int col = 0; col < M; col++) + cout << col; + cout << std::endl; + for(int i = 0; i < N; i++) { + cout << i; + for(auto col : possible[i]) + cout << col; + cout << std::endl;; + } + } }; class Solver { @@ -65,4 +80,7 @@ public: history.push_back(guess); } + void print() { + known.print(); + } };