diff options
author | Tom Smeding <tom.smeding@gmail.com> | 2018-07-01 21:11:46 +0200 |
---|---|---|
committer | Tom Smeding <tom.smeding@gmail.com> | 2018-07-01 21:11:46 +0200 |
commit | f283f00c084b3b563b923e33aabaffc4aa112e90 (patch) | |
tree | 1ed7dc59a69006ed4c6f19d2a7102fdd300d820a | |
parent | f0960d331920031eda9abe55850aa7bb8c007f18 (diff) |
Fix bug in capture-by-king
-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 { |