36 lines
842 B
C++
36 lines
842 B
C++
#pragma once
|
|
#include "global.hpp"
|
|
|
|
|
|
|
|
// For deciding the best guess
|
|
struct Weighed_guess {
|
|
int weight;
|
|
vector<int> guess;
|
|
Weighed_guess(int _w, vector<int> _g) : weight(_w), guess(_g) {}
|
|
Weighed_guess() {}
|
|
};
|
|
|
|
// Solving the game
|
|
class Solver {
|
|
Game known;
|
|
int N, M;
|
|
vector<Historic_guess> history = {};
|
|
public:
|
|
Solver(int N, int M);
|
|
|
|
vector<int> guess();
|
|
void print();
|
|
void print_unknown();
|
|
void learn(vector<int> guess, Response response);
|
|
|
|
private:
|
|
Historic_guess clean(Historic_guess hist);
|
|
vector<bool> extract_info(Historic_guess hist);
|
|
|
|
bool all_are_consistent(vector<int> supposed_sequence);
|
|
vector<int> brute_force(vector<vector<int>> *possibilities, vector<int> *chosen, int index);
|
|
|
|
int get_weight(vector<int> guess);
|
|
Weighed_guess minimax(vector<vector<int>> *possibilities, vector<int> *chosen, int index);
|
|
};
|