summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--board.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/board.cpp b/board.cpp
index 3b59aad..04f0c70 100644
--- a/board.cpp
+++ b/board.cpp
@@ -79,13 +79,15 @@ Board Board::makeInitial() {
}
bool Board::stoneFlankedH(int pos, uint8_t by) const {
- return (cells[pos-1] == by || (pos-1 == BOARDMID && cells[BOARDMID] == EMPTY)) &&
- (cells[pos+1] == by || (pos+1 == BOARDMID && cells[BOARDMID] == EMPTY));
+ if (by & (WHITE|KING)) by = WHITE|KING;
+ return ((cells[pos-1] & by) || (pos-1 == BOARDMID && cells[BOARDMID] == EMPTY)) &&
+ ((cells[pos+1] & by) || (pos+1 == BOARDMID && cells[BOARDMID] == EMPTY));
}
bool Board::stoneFlankedV(int pos, uint8_t by) const {
- return (cells[pos-N] == by || (pos-N == BOARDMID && cells[BOARDMID] == EMPTY)) &&
- (cells[pos+N] == by || (pos+N == BOARDMID && cells[BOARDMID] == EMPTY));
+ if (by & (WHITE|KING)) by = WHITE|KING;
+ return ((cells[pos-N] & by) || (pos-N == BOARDMID && cells[BOARDMID] == EMPTY)) &&
+ ((cells[pos+N] & by) || (pos+N == BOARDMID && cells[BOARDMID] == EMPTY));
}
bool Board::kingEncircled(int pos) const {