Responses should be enums
This commit is contained in:
parent
5b908ef7dd
commit
48042b7d15
4 changed files with 14 additions and 7 deletions
|
@ -9,9 +9,9 @@ using std::to_string;
|
||||||
#define UNDERLINE "\033[0;0;4m"
|
#define UNDERLINE "\033[0;0;4m"
|
||||||
|
|
||||||
|
|
||||||
string format_response(vector<int> response) {
|
string format_response(Response response) {
|
||||||
return YELLOW + to_string(response[0]) + BACK + " / " +
|
return YELLOW + to_string(response.somewhere) + BACK + " / " +
|
||||||
GREEN + to_string(response[1]) + BACK + "\n";
|
GREEN + to_string(response.correct) + BACK + "\n";
|
||||||
}
|
}
|
||||||
string format_guess(vector<int> guess) {
|
string format_guess(vector<int> guess) {
|
||||||
string r = "";
|
string r = "";
|
||||||
|
|
10
global.hpp
10
global.hpp
|
@ -8,16 +8,22 @@ using std::string;
|
||||||
using std::cout;
|
using std::cout;
|
||||||
using std::cin;
|
using std::cin;
|
||||||
|
|
||||||
|
// Generic type
|
||||||
|
struct Response {
|
||||||
|
int somewhere, correct;
|
||||||
|
Response() {}
|
||||||
|
Response(int _s, int _c) : somewhere(_s), correct(_c) {}
|
||||||
|
};
|
||||||
|
|
||||||
// Game generating
|
// Game generating
|
||||||
string get_input(string arg, vector<string> args, string prompt_text, string default_arg);
|
string get_input(string arg, vector<string> args, string prompt_text, string default_arg);
|
||||||
vector<int> generate(int N, int M);
|
vector<int> generate(int N, int M);
|
||||||
|
|
||||||
// Formatting
|
// Formatting
|
||||||
string format_response(vector<int> response);
|
string format_response(Response response);
|
||||||
string format_guess(vector<int> guess);
|
string format_guess(vector<int> guess);
|
||||||
string format_guess_history(vector<int> sequence, vector<int> guess);
|
string format_guess_history(vector<int> sequence, vector<int> guess);
|
||||||
string format_lost_sequence(vector<int> sequence);
|
string format_lost_sequence(vector<int> sequence);
|
||||||
|
|
||||||
// Validating
|
// Validating
|
||||||
vector<int> validate(vector<int> sequence, vector<int> guess);
|
Response validate(vector<int> sequence, vector<int> guess);
|
||||||
|
|
3
main.cpp
3
main.cpp
|
@ -54,7 +54,8 @@ int main(int argc, char* argv[]) {
|
||||||
// Guessing
|
// Guessing
|
||||||
vector<vector<int>> history = {};
|
vector<vector<int>> history = {};
|
||||||
for(int guesses = 0; guesses < 10; guesses++) {
|
for(int guesses = 0; guesses < 10; guesses++) {
|
||||||
vector<int> guess(N), response;
|
vector<int> guess(N);
|
||||||
|
Response response;
|
||||||
|
|
||||||
// Bot playin
|
// Bot playin
|
||||||
if(player == BOT) {
|
if(player == BOT) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "global.hpp"
|
#include "global.hpp"
|
||||||
|
|
||||||
|
|
||||||
vector<int> validate(vector<int> sequence, vector<int> guess) {
|
Response validate(vector<int> sequence, vector<int> guess) {
|
||||||
int N = sequence.size();
|
int N = sequence.size();
|
||||||
|
|
||||||
// Return values
|
// Return values
|
||||||
|
|
Loading…
Reference in a new issue