#include "global.hpp" #include #include #include struct Game { private: vector> possible; std::default_random_engine random_engine; public: int N, M; Game(int p_N, int p_M); // Get known information bool can(int n, int col); int final_color(int n); void print(); vector> list_all_possibilities(); vector> get_positions_of_colors(vector guess); // Utility functions void cannot_be(int n, int col); void must_be(int n, int must_col); void empty_color(int col); // Learning functions void if_not_here_then_nowhere(vector guess); void here(vector guess); void not_here(vector guess); void empty(vector guess); void all_are_here(vector guess); }; // For remembering guesses with their responses struct Historic_guess { vector guess, response; Historic_guess(vector p_guess, vector p_response); }; class Solver { Game known; int N, M; vector history = {}; public: Solver(int N, int M); vector guess(); void print(); void learn(vector guess, vector response); private: Historic_guess clean(Historic_guess hist); bool extract_info(Historic_guess hist); bool all_are_consistent(vector supposed_sequence); vector brute_force(vector> *possibilities, vector *chosen, int index); };