+ const mirrorSide = (Object.keys(VariantRules.ALICE_CODES).includes(this.getPiece(x,y)) ? 1 : 2);
+ return moves.filter(m => {
+ if (m.appear.length == 2) //castle
+ {
+ // If appear[i] not in vanish array, then must be empty square on other board
+ m.appear.forEach(psq => {
+ if (this.board[psq.x][psq.y] != VariantRules.EMPTY &&
+ ![m.vanish[0].y,m.vanish[1].y].includes(psq.y))
+ {
+ return false;
+ }
+ });
+ }
+ else if (this.board[m.end.x][m.end.y] != VariantRules.EMPTY)
+ {
+ // Attempt to capture
+ const piece = this.getPiece(m.end.x,m.end.y);
+ if ((mirrorSide==1 && Object.keys(VariantRules.ALICE_PIECES).includes(piece))
+ || (mirrorSide==2 && Object.keys(VariantRules.ALICE_CODES).includes(piece)))
+ {
+ return false;
+ }
+ }
+ // If the move is computed on board1, m.appear change for Alice pieces.
+ if (mirrorSide==1)
+ {
+ m.appear.forEach(psq => { //forEach: castling taken into account
+ psq.p = VariantRules.ALICE_CODES[psq.p]; //goto board2
+ });
+ }
+ else //move on board2: mark vanishing piece as Alice
+ m.vanish[0].p = VariantRules.ALICE_CODES[m.vanish[0].p]
+ return true;
+ });