Position { public final int getPiece(int square) { return squares[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 testGetPiece() throws ChessParseError { System.out.println("getPiece"); Position pos = new Position(); int result = pos.getPiece(0); assertEquals(result, Piece.EMPTY); pos = TextIO.readFEN(TextIO.startPosFEN); result = pos.getPiece(0); assertEquals(result, Piece.WROOK); for (int x = 0; x < 8; x++) { for (int y = 0; y < 2; y++) { int p1 = pos.getPiece(Position.getSquare(x, y)); int p2 = pos.getPiece(Position.getSquare(x, 7-y)); int bwDiff = Piece.BPAWN - Piece.WPAWN; assertEquals(p2, p1 + bwDiff); } } }