Game { static long perfT(MoveGen moveGen, Position pos, int depth) { if (depth == 0) return 1; long nodes = 0; MoveGen.MoveList moves = moveGen.pseudoLegalMoves(pos); MoveGen.removeIllegal(pos, moves); if (depth == 1) { int ret = moves.size; moveGen.returnMoveList(moves); return ret; } UndoInfo ui = new UndoInfo(); for (int mi = 0; mi < moves.size; mi++) { Move m = moves.m[mi]; pos.makeMove(m, ui); nodes += perfT(moveGen, pos, depth - 1); pos.unMakeMove(m, ui); } moveGen.returnMoveList(moves); return nodes; } Game(Player whitePlayer, Player blackPlayer); boolean processString(String str); final String getGameStateString(); Move getLastMove(); GameState getGameState(); boolean haveDrawOffer(); List<String> getPosHistory(); final String getMoveListString(boolean compressed); final String getPGNResultString(); ArrayList<Position> getHistory(); public Position pos; }
@Test public void testPerfT() { System.out.println("perfT"); Game game = new Game(new HumanPlayer(), new HumanPlayer()); game.processString("new"); doTestPerfT(game.pos, 5, new long[]{20,400,8902,197281,4865609,119060324,3195901860L,84998978956L}); game.processString("setpos 8/2p5/3p4/KP5r/1R3p1k/8/4P1P1/8 w - -"); doTestPerfT(game.pos, 5, new long[]{14, 191, 2812, 43238, 674624, 11030083, 178633661}); game.processString("setpos r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq -"); doTestPerfT(game.pos, 4, new long[]{48,2039,97862,4085603,193690690}); }