Debug what solver learns via human play

This commit is contained in:
Matúš Púll 2024-11-03 10:48:08 +01:00
parent d8369930e9
commit 642dbb2b70
2 changed files with 29 additions and 0 deletions

View file

@ -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);

View file

@ -1,7 +1,9 @@
#pragma once
#include <vector>
#include <iostream>
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();
}
};