Position { public final int getKingSq(boolean white) { return white ? wKingSq : bKingSq; } 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 testGetKingSq() throws ChessParseError { System.out.println("getKingSq"); Position pos = TextIO.readFEN(TextIO.startPosFEN); assertEquals(TextIO.getSquare("e1"), pos.getKingSq(true)); assertEquals(TextIO.getSquare("e8"), pos.getKingSq(false)); pos = TextIO.readFEN("r1bq1bnr/ppppkppp/2n5/1B2p3/4P3/5N2/PPPP1PPP/RNBQK2R w KQ - 0 4"); assertEquals(TextIO.getSquare("e1"), pos.getKingSq(true)); assertEquals(TextIO.getSquare("e7"), pos.getKingSq(false)); UndoInfo ui = new UndoInfo(); pos.makeMove(TextIO.stringToMove(pos, "o-o"), ui); assertEquals(TextIO.getSquare("g1"), pos.getKingSq(true)); assertEquals(TextIO.getSquare("e7"), pos.getKingSq(false)); pos.makeMove(TextIO.stringToMove(pos, "Kd6"), ui); assertEquals(TextIO.getSquare("g1"), pos.getKingSq(true)); assertEquals(TextIO.getSquare("d6"), pos.getKingSq(false)); }