diff --git a/main.cpp b/main.cpp index 114b0f8..9798ac0 100644 --- a/main.cpp +++ b/main.cpp @@ -75,6 +75,7 @@ public: T &operator[](size_t index) { return data[index]; } + int size() { return length; } @@ -186,7 +187,7 @@ void bubbleSort(pair *a) { } -void printScores(int *points) { +void printScores(int *points, char blacklist) { pair *arr = static_cast *>(alloc(26 * sizeof(pair))); for (int i = 0; i < 26; i++) { pair 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); }