+ getLongestCaptures_aux([x, y], color, locSteps) {
+ let res = [];
+ const L = locSteps.length;
+ const lastStep = (L > 0 ? locSteps[L-1] : null);
+ for (let s of V.steps[V.BISHOP]) {
+ if (!!lastStep && s[0] == -lastStep[0] && s[1] == -lastStep[1]) continue;
+ const [i, j] = [x + s[0], y + s[1]];
+ if (
+ V.OnBoard(i + s[0], j + s[1]) &&
+ this.board[i + s[0]][j + s[1]] == V.EMPTY &&
+ this.board[i][j] != V.EMPTY &&
+ this.getColor(i, j) != color
+ ) {
+ const move = this.getBasicMove([x, y], [i + s[0], j + s[1]], [i, j]);
+ locSteps.push(s);
+ V.PlayOnBoard(this.board, move);
+ const nextRes =
+ this.getLongestCaptures_aux([i + s[0], j + s[1]], color, locSteps);
+ res.push(1 + nextRes);
+ locSteps.pop();
+ V.UndoOnBoard(this.board, move);
+ }
+ }
+ if (res.length == 0) return 0;
+ return Math.max(...res);
+ }
+