blacklist player
This commit is contained in:
parent
937d223a8c
commit
cf468cfe08
15
main.cpp
15
main.cpp
@ -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;
|
||||||
}
|
}
|
||||||
@ -323,23 +324,23 @@ void solve(Moves moves, char **board) {
|
|||||||
board[moveX][moveY] = toLowerCase(player);
|
board[moveX][moveY] = toLowerCase(player);
|
||||||
|
|
||||||
// TODO:
|
// TODO:
|
||||||
if (!(moveX&1) && (moveY&1)) {
|
if (!(moveX & 1) && (moveY & 1)) {
|
||||||
solveVertical(moveX, moveY, board, points, moves.x, moves.y, player);
|
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);
|
solveHorizontal(moveX, moveY, board, points, moves.y, player);
|
||||||
} else {
|
} else {
|
||||||
pt "Invalid move by: " << player << " at (x, y): (" << moveX << ", " << moveY << ")" << nl;
|
pt "Invalid move by: " << player << " at (x, y): (" << moveX << ", " << moveY << ")" << nl;
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user