summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2018-03-12 13:55:19 +0100
committertomsmeding <tom.smeding@gmail.com>2018-03-12 13:55:19 +0100
commit3de177458e8ca38cdae100f8bf5d6d75bcce0d14 (patch)
tree473ee8e1ef789f1a80eab7b35c9894ef4768d4b3
parentdd3d84dc02d7d7fc782fe2734b9ab6fd028b1346 (diff)
Fix bishop movementHEADmaster
-rw-r--r--board.cpp48
1 files changed, 28 insertions, 20 deletions
diff --git a/board.cpp b/board.cpp
index 69a7094..5425d7b 100644
--- a/board.cpp
+++ b/board.cpp
@@ -160,33 +160,41 @@ vector<Board> Board::subsequents() const {
break;
case BISHOP:
- for (int i2 = i - 9; i2 >= 0; i2 -= 9) {
- if (at(i2) == EMPTY || colour(at(i2)) != clr) {
- subs.push_back(newWith(SHIFTER(i, i2)));
+ if (i % 8 != 0) {
+ for (int i2 = i - 9; i2 >= 0; i2 -= 9) {
+ if (at(i2) == EMPTY || colour(at(i2)) != clr) {
+ subs.push_back(newWith(SHIFTER(i, i2)));
+ }
+ if (at(i2) != EMPTY) break;
+ if (i2 % 8 == 0) break;
}
- if (at(i2) != EMPTY) break;
- if (i2 % 8 == 0) break;
}
- for (int i2 = i - 7; i2 >= 0; i2 -= 7) {
- if (at(i2) == EMPTY || colour(at(i2)) != clr) {
- subs.push_back(newWith(SHIFTER(i, i2)));
+ if (i % 8 != 7) {
+ for (int i2 = i - 7; i2 >= 0; i2 -= 7) {
+ if (at(i2) == EMPTY || colour(at(i2)) != clr) {
+ subs.push_back(newWith(SHIFTER(i, i2)));
+ }
+ if (at(i2) != EMPTY) break;
+ if (i2 % 8 == 7) break;
}
- if (at(i2) != EMPTY) break;
- if (i2 % 8 == 7) break;
}
- for (int i2 = i + 7; i2 < 64; i2 += 7) {
- if (at(i2) == EMPTY || colour(at(i2)) != clr) {
- subs.push_back(newWith(SHIFTER(i, i2)));
+ if (i % 8 != 0) {
+ for (int i2 = i + 7; i2 < 64; i2 += 7) {
+ if (at(i2) == EMPTY || colour(at(i2)) != clr) {
+ subs.push_back(newWith(SHIFTER(i, i2)));
+ }
+ if (at(i2) != EMPTY) break;
+ if (i2 % 8 == 0) break;
}
- if (at(i2) != EMPTY) break;
- if (i2 % 8 == 0) break;
}
- for (int i2 = i + 9; i2 < 64; i2 += 9) {
- if (at(i2) == EMPTY || colour(at(i2)) != clr) {
- subs.push_back(newWith(SHIFTER(i, i2)));
+ if (i % 8 != 7) {
+ for (int i2 = i + 9; i2 < 64; i2 += 9) {
+ if (at(i2) == EMPTY || colour(at(i2)) != clr) {
+ subs.push_back(newWith(SHIFTER(i, i2)));
+ }
+ if (at(i2) != EMPTY) break;
+ if (i2 % 8 == 7) break;
}
- if (at(i2) != EMPTY) break;
- if (i2 % 8 == 7) break;
}
break;