updateCastleFlags(move, piece, twoKings) {
    const c = V.GetOppCol(this.turn);
    const firstRank = (c == "w" ? V.size.x - 1 : 0);
    // Update castling flags if castling pieces moved or were captured
    const oppCol = V.GetOppCol(c);
    const oppFirstRank = V.size.x - 1 - firstRank;
    if (move.start.x == firstRank) {
      if (piece == V.KING || (!twoKings && piece == V.QUEEN)) {
        if (this.castleFlags[c][1] == move.start.y)
          this.castleFlags[c][1] = 8;
        else if (this.castleFlags[c][2] == move.start.y)
          this.castleFlags[c][2] = 8;
        // Else: the flag is already turned off
      }
    }
    else if (
      move.start.x == firstRank && //our rook moves?
      [this.castleFlags[c][0], this.castleFlags[c][3]].includes(move.start.y)
    ) {
      const flagIdx = (move.start.y == this.castleFlags[c][0] ? 0 : 3);
      this.castleFlags[c][flagIdx] = 8;
    } else if (
      move.end.x == oppFirstRank && //we took opponent rook?
      [this.castleFlags[oppCol][0], this.castleFlags[oppCol][3]]
        .includes(move.end.y)
    ) {
      const flagIdx = (move.end.y == this.castleFlags[oppCol][0] ? 0 : 3);
      this.castleFlags[oppCol][flagIdx] = 8;
    }
  }
// "twoKings" arg for the similar Twokings variant.
"twoKings" arg for the similar Twokings variant.
" twoKings " arg for the similar Twokings variant .
updateCastleFlags(move, piece, twoKings) {
    const c = V.GetOppCol(this.turn);
    const firstRank = (c == "w" ? V.size.x - 1 : 0);
    const oppCol = V.GetOppCol(c);
    const oppFirstRank = V.size.x - 1 - firstRank;
    if (move.start.x == firstRank) {
      if (piece == V.KING || (!twoKings && piece == V.QUEEN)) {
        if (this.castleFlags[c][1] == move.start.y)
          this.castleFlags[c][1] = 8;
        else if (this.castleFlags[c][2] == move.start.y)
          this.castleFlags[c][2] = 8;
      }
    }
    else if (
      move.start.x == firstRank && 
      [this.castleFlags[c][0], this.castleFlags[c][3]].includes(move.start.y)
    ) {
      const flagIdx = (move.start.y == this.castleFlags[c][0] ? 0 : 3);
      this.castleFlags[c][flagIdx] = 8;
    } else if (
      move.end.x == oppFirstRank && 
      [this.castleFlags[oppCol][0], this.castleFlags[oppCol][3]]
        .includes(move.end.y)
    ) {
      const flagIdx = (move.end.y == this.castleFlags[oppCol][0] ? 0 : 3);
      this.castleFlags[oppCol][flagIdx] = 8;
    }
  }
updateCastleFlags ( move , piece , twoKings ) { const c = V . GetOppCol ( this . turn ) ; const firstRank = ( c == "w" ? V . size . x - 1 : 0 ) ; const oppCol = V . GetOppCol ( c ) ; const oppFirstRank = V . size . x - 1 - firstRank ; if ( move . start . x == firstRank ) { if ( piece == V . KING || ( ! twoKings && piece == V . QUEEN ) ) { if ( this . castleFlags [ c ] [ 1 ] == move . start . y ) this . castleFlags [ c ] [ 1 ] = 8 ; else if ( this . castleFlags [ c ] [ 2 ] == move . start . y ) this . castleFlags [ c ] [ 2 ] = 8 ; } } else if ( move . start . x == firstRank && [ this . castleFlags [ c ] [ 0 ] , this . castleFlags [ c ] [ 3 ] ] . includes ( move . start . y ) ) { const flagIdx = ( move . start . y == this . castleFlags [ c ] [ 0 ] ? 0 : 3 ) ; this . castleFlags [ c ] [ flagIdx ] = 8 ; } else if ( move . end . x == oppFirstRank && [ this . castleFlags [ oppCol ] [ 0 ] , this . castleFlags [ oppCol ] [ 3 ] ] . includes ( move . end . y ) ) { const flagIdx = ( move . end . y == this . castleFlags [ oppCol ] [ 0 ] ? 0 : 3 ) ; this . castleFlags [ oppCol ] [ flagIdx ] = 8 ; } }
"twoKings" arg for the similar Twokings variant.
" twoKings " arg for the similar Twokings variant .
// Update castling flags if castling pieces moved or were captured // Else: the flag is already turned off //our rook moves? //we took opponent rook?