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) {
return data[index];
}
int size() {
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>)));
for (int i = 0; i < 26; i++) {
pair<char, int> p;
@ -202,7 +203,7 @@ void printScores(int *points) {
for (int i = 0; i < 26; i++) {
if (arr[i].second != -1) {
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;
}
}
@ -315,7 +316,7 @@ void solve(Moves moves, char **board) {
board[moveX][moveY] = 'X';
printBoard(board, moves.x, moves.y);
printScores(points);
printScores(points, player);
pt "Exiting.." << nl;
return;
}
@ -323,23 +324,23 @@ void solve(Moves moves, char **board) {
board[moveX][moveY] = toLowerCase(player);
// TODO:
if (!(moveX&1) && (moveY&1)) {
if (!(moveX & 1) && (moveY & 1)) {
solveVertical(moveX, moveY, board, points, moves.x, moves.y, player);
} else if ((moveX&1) && !(moveY&1)) {
} else if ((moveX & 1) && !(moveY & 1)) {
solveHorizontal(moveX, moveY, board, points, moves.y, player);
} else {
pt "Invalid move by: " << player << " at (x, y): (" << moveX << ", " << moveY << ")" << nl;
board[moveX][moveY] = 'X';
printBoard(board, moves.x, moves.y);
printScores(points);
printScores(points, player);
pt "Exiting.." << nl;
return;
}
}
printBoard(board, moves.x, moves.y);
printScores(points);
printScores(points, '\0');
dealloc(points);
}