Print sequence if lost
This commit is contained in:
parent
35ae7de10b
commit
e3940d5a58
2 changed files with 13 additions and 1 deletions
6
main.cpp
6
main.cpp
|
@ -59,6 +59,7 @@ int main(void) {
|
||||||
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;
|
||||||
|
cout << "Guess " << history.size() << " : ";
|
||||||
|
|
||||||
// Bot playing
|
// Bot playing
|
||||||
if(player == BOT) {
|
if(player == BOT) {
|
||||||
|
@ -80,7 +81,7 @@ int main(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
history.push_back(guess);
|
history.push_back(guess);
|
||||||
if(response[1] == N) break;
|
if(history.back() == sequence) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Terminal clearing
|
// Terminal clearing
|
||||||
|
@ -91,5 +92,8 @@ int main(void) {
|
||||||
for(auto guess : history)
|
for(auto guess : history)
|
||||||
cout << format_guess_history(sequence, guess) << std::endl;
|
cout << format_guess_history(sequence, guess) << std::endl;
|
||||||
|
|
||||||
|
if(history.back() != sequence)
|
||||||
|
cout << format_lost_sequence(sequence) << std::endl;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@ vector<int> validate(vector<int> sequence, vector<int> guess) {
|
||||||
|
|
||||||
#define YELLOW "\033[33m"
|
#define YELLOW "\033[33m"
|
||||||
#define GREEN "\033[32m"
|
#define GREEN "\033[32m"
|
||||||
|
#define RED "\033[31m"
|
||||||
#define BACK "\033[0m"
|
#define BACK "\033[0m"
|
||||||
|
|
||||||
string format_response(vector<int> response) {
|
string format_response(vector<int> response) {
|
||||||
|
@ -92,3 +93,10 @@ string format_guess_history(vector<int> sequence, vector<int> guess) {
|
||||||
r_string += s + " ";
|
r_string += s + " ";
|
||||||
return r_string;
|
return r_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string format_lost_sequence(vector<int> sequence) {
|
||||||
|
string r = "";
|
||||||
|
for(int col : sequence)
|
||||||
|
r += RED + to_string(col) + BACK + " ";
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue