blacklist player

This commit is contained in:
Sandipsinh Rathod 2024-10-10 18:52:28 -04:00
parent 937d223a8c
commit cf468cfe08

@ -75,6 +75,7 @@ public:
T &operator[](size_t index) { T &operator[](size_t index) {
return data[index]; return data[index];
} }
int size() { int size() {
return length; return length;
} }
@ -186,7 +187,7 @@ void bubbleSort(pair<char, int> *a) {
} }
void printScores(int *points) { void printScores(int *points, char blacklist) {
pair<char, int> *arr = static_cast<pair<char, int> *>(alloc(26 * sizeof(pair<char, int>))); pair<char, int> *arr = static_cast<pair<char, int> *>(alloc(26 * sizeof(pair<char, int>)));
for (int i = 0; i < 26; i++) { for (int i = 0; i < 26; i++) {
pair<char, int> p; pair<char, int> p;
@ -202,7 +203,7 @@ void printScores(int *points) {
for (int i = 0; i < 26; i++) { for (int i = 0; i < 26; i++) {
if (arr[i].second != -1) { if (arr[i].second != -1) {
pt arr[i].first << ": " << arr[i].second << " boxes" << ( pt arr[i].first << ": " << arr[i].second << " boxes" << (
i == 25 || prev == arr[i].second ? " (win)\n" : nl); (i == 25 || prev == arr[i].second) && arr[i].first != blacklist ? " (win)\n" : nl);
prev = arr[i].second; prev = arr[i].second;
} }
} }
@ -315,7 +316,7 @@ void solve(Moves moves, char **board) {
board[moveX][moveY] = 'X'; board[moveX][moveY] = 'X';
printBoard(board, moves.x, moves.y); printBoard(board, moves.x, moves.y);
printScores(points); printScores(points, player);
pt "Exiting.." << nl; pt "Exiting.." << nl;
return; return;
} }
@ -332,14 +333,14 @@ void solve(Moves moves, char **board) {
board[moveX][moveY] = 'X'; board[moveX][moveY] = 'X';
printBoard(board, moves.x, moves.y); printBoard(board, moves.x, moves.y);
printScores(points); printScores(points, player);
pt "Exiting.." << nl; pt "Exiting.." << nl;
return; return;
} }
} }
printBoard(board, moves.x, moves.y); printBoard(board, moves.x, moves.y);
printScores(points); printScores(points, '\0');
dealloc(points); dealloc(points);
} }