Position { public final void setPiece(int square, int piece) { int removedPiece = squares[square]; squares[square] = piece; hashKey ^= psHashKeys[removedPiece][square]; hashKey ^= psHashKeys[piece][square]; final long sqMask = 1L << square; pieceTypeBB[removedPiece] &= ~sqMask; pieceTypeBB[piece] |= sqMask; if (removedPiece != Piece.EMPTY) { int pVal = Evaluate.pieceValue[removedPiece]; if (Piece.isWhite(removedPiece)) { wMtrl -= pVal; whiteBB &= ~sqMask; if (removedPiece == Piece.WPAWN) { wMtrlPawns -= pVal; pHashKey ^= psHashKeys[Piece.WPAWN][square]; } } else { bMtrl -= pVal; blackBB &= ~sqMask; if (removedPiece == Piece.BPAWN) { bMtrlPawns -= pVal; pHashKey ^= psHashKeys[Piece.BPAWN][square]; } } } if (piece != Piece.EMPTY) { int pVal = Evaluate.pieceValue[piece]; if (Piece.isWhite(piece)) { wMtrl += pVal; whiteBB |= sqMask; if (piece == Piece.WPAWN) { wMtrlPawns += pVal; pHashKey ^= psHashKeys[Piece.WPAWN][square]; } if (piece == Piece.WKING) wKingSq = square; } else { bMtrl += pVal; blackBB |= sqMask; if (piece == Piece.BPAWN) { bMtrlPawns += pVal; pHashKey ^= psHashKeys[Piece.BPAWN][square]; } if (piece == Piece.BKING) bKingSq = square; } } psScore1[removedPiece] -= Evaluate.psTab1[removedPiece][square]; psScore2[removedPiece] -= Evaluate.psTab2[removedPiece][square]; psScore1[piece] += Evaluate.psTab1[piece][square]; psScore2[piece] += Evaluate.psTab2[piece][square]; } Position();  Position(Position other); @Override boolean equals(Object o); @Override int hashCode(); final long zobristHash(); final long pawnZobristHash(); final long kingZobristHash(); final long historyHash(); final boolean drawRuleEquals(Position other); final void setWhiteMove(boolean whiteMove); static int getSquare(int x, int y); static int getX(int square); static int getY(int square); static boolean darkSquare(int x, int y); final int getPiece(int square); final void setPiece(int square, int piece); final boolean a1Castle(); final boolean h1Castle(); final boolean a8Castle(); final boolean h8Castle(); final int getCastleMask(); final void setCastleMask(int castleMask); final int getEpSquare(); final void setEpSquare(int epSquare); final int getKingSq(boolean white); final void makeMove(Move move, UndoInfo ui); final void unMakeMove(Move move, UndoInfo ui); final void makeSEEMove(Move move, UndoInfo ui); final void unMakeSEEMove(Move move, UndoInfo ui); final String toString(); public int[] squares; public long[] pieceTypeBB; public long whiteBB; public short[] psScore1; public boolean whiteMove; static final int A1_CASTLE; static final int H1_CASTLE; static final int A8_CASTLE; static final int H8_CASTLE; public int fullMoveCounter; public int wKingSq; public int wMtrl; public int bMtrl; public int wMtrlPawns; public int bMtrlPawns; }
@Test public void testSetPiece() { System.out.println("setPiece"); Position instance = new Position(); assertEquals(Piece.EMPTY, instance.getPiece(Position.getSquare(0, 0))); instance.setPiece(Position.getSquare(3, 4), Piece.WKING); assertEquals(Piece.WKING, instance.getPiece(Position.getSquare(3, 4))); }