logik/global.hpp

69 lines
1.6 KiB
C++

#pragma once
#include <iostream>
#include <vector>
#include <string>
#include <random>
using std::vector;
using std::string;
using std::cout;
using std::cin;
// Generic type
struct Response {
int somewhere, correct;
Response() {}
Response(int _s, int _c) : somewhere(_s), correct(_c) {}
};
// Game generating
string get_input(string arg, vector<string> args, string prompt_text, string default_arg);
vector<int> generate(int N, int M);
// Formatting
string format_response(Response response);
string format_guess(vector<int> guess);
string format_guess_history(vector<int> sequence, vector<int> guess);
string format_lost_sequence(vector<int> sequence);
// Validating
Response validate(vector<int> sequence, vector<int> guess);
// Game remembering
struct Game {
private:
vector<vector<bool>> possible;
vector<bool> empty_colors;
vector<int> final;
std::default_random_engine random_engine;
public:
int N, M;
Game(int _N, int _M);
// Get known information
bool can(int n, int col);
int final_color(int n);
bool is_empty(int col);
void print();
vector<vector<int>> list_all_possibilities();
vector<vector<int>> get_positions_of_colors(vector<int> 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
bool if_not_here_then_nowhere(vector<int> guess);
void here(vector<int> guess);
void not_here(vector<int> guess);
void empty(vector<int> guess);
void all_are_here(vector<int> guess);
};
// Guess-response remembering
struct Historic_guess {
vector<int> guess;
Response response;
Historic_guess(vector<int> _guess, Response _response);
};