Evaluate { private int tradeBonus(Position pos) { final int wM = pos.wMtrl; final int bM = pos.bMtrl; final int wPawn = pos.wMtrlPawns; final int bPawn = pos.bMtrlPawns; final int deltaScore = wM - bM; int pBonus = 0; pBonus += interpolate((deltaScore > 0) ? wPawn : bPawn, 0, -30 * deltaScore / 100, 6 * pV, 0); pBonus += interpolate((deltaScore > 0) ? bM : wM, 0, 30 * deltaScore / 100, qV + 2 * rV + 2 * bV + 2 * nV, 0); return pBonus; } Evaluate(); final int evalPos(Position pos);  }
@Test public void testTradeBonus() throws ChessParseError { System.out.println("tradeBonus"); String fen = "8/5k2/6r1/2p1p3/3p4/2P2N2/3PPP2/4K1R1 w - - 0 1"; Position pos = TextIO.readFEN(fen); int score1 = evalWhite(pos); UndoInfo ui = new UndoInfo(); pos.makeMove(TextIO.stringToMove(pos, "Rxg6"), ui); pos.makeMove(TextIO.stringToMove(pos, "Kxg6"), ui); int score2 = evalWhite(pos); assertTrue(score2 > score1); pos = TextIO.readFEN(fen); pos.makeMove(TextIO.stringToMove(pos, "cxd4"), ui); pos.makeMove(TextIO.stringToMove(pos, "cxd4"), ui); score2 = evalWhite(pos); assertTrue(score2 < score1); pos = TextIO.readFEN("8/8/1b2b3/4kp2/5N2/4NKP1/6B1/8 w - - 0 62"); score1 = evalWhite(pos); pos.makeMove(TextIO.stringToMove(pos, "Nxe6"), ui); pos.makeMove(TextIO.stringToMove(pos, "Kxe6"), ui); score2 = evalWhite(pos); assertTrue(score2 > score1); }