- return (
- super.getPotentialMovesFrom([x, y])
- .filter(m => m.end.y != 4 || ![0, 8].includes(m.end.x))
- );
+ const moves = super.getPotentialMovesFrom([x, y])
+ .filter(m => m.end.y != 4 || ![0, 8].includes(m.end.x));
+ // If bishop stuck in a corner: allow to jump over the next obstacle
+ if (moves.length == 0 && piece == V.BISHOP) {
+ if (
+ x == 0 && y == 0 &&
+ this.board[1][1] != V.EMPTY &&
+ this.board[2][2] == V.EMPTY
+ ) {
+ return [super.getBasicMove([x, y], [2, 2])];
+ }
+ if (
+ x == 0 && y == 8 &&
+ this.board[1][7] != V.EMPTY &&
+ this.board[2][6] == V.EMPTY
+ ) {
+ return [super.getBasicMove([x, y], [2, 6])];
+ }
+ if (
+ x == 8 && y == 0 &&
+ this.board[7][1] != V.EMPTY &&
+ this.board[6][2] == V.EMPTY
+ ) {
+ return [super.getBasicMove([x, y], [6, 2])];
+ }
+ if (
+ x == 8 && y == 8 &&
+ this.board[7][7] != V.EMPTY &&
+ this.board[6][6] == V.EMPTY
+ ) {
+ return [super.getBasicMove([x, y], [6, 6])];
+ }
+ }
+ return moves;