diff options
-rw-r--r-- | board.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -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 { |