#pragma once #include using std::vector; struct Game { int N, M; // Table of NxM saying which position can hold which color vector> possible; // Searched sequence vector sequence; Game(int p_N, int p_M) : N(p_N), M(p_M) { possible = vector>(N, vector(M, 1)); sequence = vector(N, -1); } // Learning functions void cannot_be(int n, int col) { possible[n][col] = false; } void must_be(int must_n, int col) { for(int n = 0; n < N; n++) if(n != must_n) possible[n][col] = 0; } void empty_color(int col) { for(int n = 0; n < N; n++) possible[n][col] = 0; } }; class Solver { Game known; vector> history = {}; public: Solver(int p_N, int p_M) : known({p_N, p_M}) {} vector guess() { // TODO return {}; } void learn_back(vector guess) { // TODO } void learn(vector guess, vector response) { // Reduce color positions if(response[0] == 0 && response[1] == 0) { for(int col : guess) known.empty_color(col); } else if(response[1] == 0) {; for(int n = 0; n < known.N; n++) known.cannot_be(n, guess[n]); } else if(response[0] == 0) { for(int n = 0; n < known.N; n++) known.must_be(n, guess[n]); } else { // TODO nenula / nenula } // Learn from previous guesses for(vector past_guess : history) learn_back(past_guess); history.push_back(guess); } };