Exemple #1
0
  private void updateAvailableCastlings(Move move, Board board) {
    Piece srcPiece = board.at(move.getDst());

    if (srcPiece.isType(PieceType.KING)) {
      availableCastlings.get(srcPiece.color()).clear();
    }

    if (srcPiece.isType(PieceType.ROOK) && move.getSource().getCol() == 0) {
      availableCastlings.get(srcPiece.color()).remove(CastlingType.CASTLING_QUEEN_SIDE);
    }

    if (srcPiece.isType(PieceType.ROOK) && move.getSource().getCol() == 7) {
      availableCastlings.get(srcPiece.color()).remove(CastlingType.CASTLING_KING_SIDE);
    }
  }
Exemple #2
0
  public void notifyMove(Move move, Board board) {
    updateAvailableCastlings(move, board);

    Color opponent = board.at(move.getDst()).color().opponent();

    if (availableCastlings.get(opponent).contains(CastlingType.CASTLING_KING_SIDE)
        && MoveEvaluator.canKingSideCastling(opponent, board)) {
      castlings.add(new CastlingKingSide(opponent, board));
    }

    if (availableCastlings.get(opponent).contains(CastlingType.CASTLING_QUEEN_SIDE)
        && MoveEvaluator.canQueenSideCastling(opponent, board)) {
      castlings.add(new CastlingQueenSide(opponent, board));
    }
  }