Position { final public boolean drawRuleEquals(Position other) { for (int i = 0; i < 64; i++) { if (squares[i] != other.squares[i]) return false; } if (whiteMove != other.whiteMove) return false; if (castleMask != other.castleMask) return false; if (epSquare != other.epSquare) return false; return true; } 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 testDrawRuleEquals() throws ChessParseError { System.out.println("drawRuleEquals"); Position pos = TextIO.readFEN(TextIO.startPosFEN); Position origPos = new Position(pos); UndoInfo ui = new UndoInfo(); pos.makeMove(TextIO.stringToMove(pos, "Nf3"), ui); assertEquals(false, pos.drawRuleEquals(origPos)); pos.makeMove(TextIO.stringToMove(pos, "Nf6"), ui); assertEquals(false, pos.drawRuleEquals(origPos)); pos.makeMove(TextIO.stringToMove(pos, "Ng1"), ui); assertEquals(false, pos.drawRuleEquals(origPos)); pos.makeMove(TextIO.stringToMove(pos, "Ng8"), ui); assertEquals(true, pos.drawRuleEquals(origPos)); assertEquals(false, pos.equals(origPos)); String fen = "r1bqkb1r/pppp1ppp/2n2n2/1B2p3/4P3/5N2/PPPP1PPP/RNBQK2R w KQkq - 0 1"; pos = TextIO.readFEN(fen); origPos = new Position(pos); pos.makeMove(TextIO.stringToMove(pos, "Ke2"), ui); assertEquals(false, pos.drawRuleEquals(origPos)); pos.makeMove(TextIO.stringToMove(pos, "Be7"), ui); assertEquals(false, pos.drawRuleEquals(origPos)); pos.makeMove(TextIO.stringToMove(pos, "Ke1"), ui); assertEquals(false, pos.drawRuleEquals(origPos)); pos.makeMove(TextIO.stringToMove(pos, "Bf8"), ui); assertEquals(false, pos.drawRuleEquals(origPos)); pos = TextIO.readFEN(TextIO.startPosFEN); pos.makeMove(TextIO.stringToMove(pos, "c4"), ui); pos.makeMove(TextIO.stringToMove(pos, "a6"), ui); pos.makeMove(TextIO.stringToMove(pos, "c5"), ui); pos.makeMove(TextIO.stringToMove(pos, "b5"), ui); assertEquals(Position.getSquare(1, 5), pos.getEpSquare()); origPos = new Position(pos); pos.makeMove(TextIO.stringToMove(pos, "Nc3"), ui); pos.makeMove(TextIO.stringToMove(pos, "Nc6"), ui); pos.makeMove(TextIO.stringToMove(pos, "Nb1"), ui); pos.makeMove(TextIO.stringToMove(pos, "Nb8"), ui); assertEquals(false, pos.drawRuleEquals(origPos)); }