diff --git a/main.cpp b/main.cpp index 847c984..53d83b1 100644 --- a/main.cpp +++ b/main.cpp @@ -37,11 +37,21 @@ int main(void) { if(gen == RANDOM) sequence = generate(N, M); else if(gen == HUMAN) { - cout << "Enter " << N << " space-separated colors from 0 to " << M-1 << std::endl; + cout << "Enter " << N << " space-separated numbers from 0 to " << M-1 << std::endl; for(int n = 0; n < N; n++) cin >> sequence[n]; } + // Terminal clearing + cout << std::endl; + + // Human info + if(player == HUMAN) { + cout << "Guesses are " << N << " space-separated numbers from 0 to " << M-1 << std::endl + << "Responses are in format [correct out of place] / [correct in place]" << std::endl; + cout << std::endl; + } + // Init solver Solver bot(N, M); @@ -62,7 +72,6 @@ int main(void) { // Human playing else if(player == HUMAN) { - cout << "Guess " << N << " space-separated colors from 0 to " << M-1 << std::endl; for(int n = 0; n < N; n++) cin >> guess[n]; @@ -74,8 +83,11 @@ int main(void) { if(response[1] == N) break; } + // Terminal clearing + cout << std::endl; + // Print game statistics - cout << "How well did the game go\n"; + cout << "How did the game go\n"; for(auto guess : history) cout << format_guess_history(sequence, guess) << std::endl; diff --git a/validate.hpp b/validate.hpp index 2f8c13f..67f4e35 100644 --- a/validate.hpp +++ b/validate.hpp @@ -6,6 +6,11 @@ using std::vector; using std::string; using std::to_string; + +#define YELLOW "\033[33m" +#define GREEN "\033[32m" +#define BACK "\033[0m" + vector validate(vector sequence, vector guess) { int S = sequence.size(); @@ -40,7 +45,8 @@ vector validate(vector sequence, vector guess) { } string format_response(vector response) { - return to_string(response[0]) + " somewhere / " + to_string(response[1]) + " on the right spot\n"; + return YELLOW + to_string(response[0]) + BACK + " / " + + GREEN + to_string(response[1]) + BACK + "\n"; } string format_guess(vector guess) { string r = ""; @@ -56,7 +62,7 @@ string format_guess_history(vector sequence, vector guess) { // Find correct values for(int i = 0; i < N; i++) { if(sequence[i] == guess[i]) { - r[i] = "\033[32m" + to_string(guess[i]) + "\033[0m"; + r[i] = GREEN + to_string(guess[i]) + BACK; guess[i] = -1; sequence[i] = -1; } @@ -67,7 +73,7 @@ string format_guess_history(vector sequence, vector guess) { if(guess[i] == -1) continue; for(int j = 0; j < N; j++) { if(sequence[j] == guess[i]) { - r[i] = "\033[33m" + to_string(guess[i]) + "\033[0m"; + r[i] = YELLOW + to_string(guess[i]) + BACK; guess[i] = -1; sequence[i] = -1; break;