History { public final int getHistScore(Position pos, Move m) { int p = pos.getPiece(m.from); int ret = score[p][m.to]; if (ret >= 0) return ret; int succ = countSuccess[p][m.to]; int fail = countFail[p][m.to]; if (succ + fail > 0) { ret = succ * 49 / (succ + fail); } else { ret = 0; } score[p][m.to] = ret; return ret; } History(); void init(); final void addSuccess(Position pos, Move m, int depth); final void addFail(Position pos, Move m, int depth); final int getHistScore(Position pos, Move m);  }
@Test public void testGetHistScore() throws ChessParseError { System.out.println("getHistScore"); Position pos = TextIO.readFEN(TextIO.startPosFEN); History hs = new History(); Move m1 = TextIO.stringToMove(pos, "e4"); Move m2 = TextIO.stringToMove(pos, "d4"); assertEquals(0, hs.getHistScore(pos, m1)); hs.addSuccess(pos, m1, 1); assertEquals(1 * 49 / 1, hs.getHistScore(pos, m1)); assertEquals(0, hs.getHistScore(pos, m2)); hs.addSuccess(pos, m1, 1); assertEquals(1 * 49 / 1, hs.getHistScore(pos, m1)); assertEquals(0, hs.getHistScore(pos, m2)); hs.addFail(pos, m1, 1); assertEquals(2 * 49 / 3, hs.getHistScore(pos, m1)); assertEquals(0, hs.getHistScore(pos, m2)); hs.addFail(pos, m1, 1); assertEquals(2 * 49 / 4, hs.getHistScore(pos, m1)); assertEquals(0, hs.getHistScore(pos, m2)); hs.addSuccess(pos, m2, 1); assertEquals(2 * 49 / 4, hs.getHistScore(pos, m1)); assertEquals(1 * 49 / 1, hs.getHistScore(pos, m2)); }