From f283f00c084b3b563b923e33aabaffc4aa112e90 Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Sun, 1 Jul 2018 21:11:46 +0200 Subject: Fix bug in capture-by-king --- board.cpp | 10 ++++++---- 1 file 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 { -- cgit v1.2.3-70-g09d2