private ulong InternalPerftWithHash(int depth, int p, PerfResults res, ITranspositionTable table) { ulong count = 0; if (table.ProbeMovesCount(ZKey, out count, depth)) { res.HashHit++; return(count); } bool inCheck = TestInCheck(ToMove); int moveCount = GetMoves(p, prftMoves); if (depth == 1) { table.StoreMovesCount(ZKey, (ulong)moveCount, 1); return((ulong)moveCount); } if (depth == 0) { return(1); } for (int i = p; i < p + moveCount; ++i) { Side moving = ToMove; Move(prftMoves[i]); count += InternalPerftWithHash(depth - 1, p + moveCount, res, table); UndoMove(); } table.StoreMovesCount(ZKey, count, depth); return(count); }
public DivideResults Divide(int depth) { int[] divideMoves = new int[1000]; bool inCheck = TestInCheck(ToMove); int nodes = GetMoves(0, divideMoves); ulong movescount = 0; for (int i = 0; i < nodes; ++i) { Move(divideMoves[i]); PerfResults res = Perft(Math.Max(0, depth - 1), false, null); if (null != DividePartialResult) { this.CurrentDivideMove = MovePackHelper.GetAlgebraicString(divideMoves[i]); this.CurrentDivideNodeCount = (long)res.MovesCount; movescount += res.MovesCount; DividePartialResult(this, EventArgs.Empty); } UndoMove(divideMoves[i]); } return(new DivideResults() { NodesCount = (ulong)nodes, MovesCount = movescount }); }
public PerfResults Perft(int depth, bool useHash, ITranspositionTable table) { if (useHash == false) { prftMoves = new int[1000]; Stopwatch sw = new Stopwatch(); PerfResults perft = new PerfResults(); sw.Start(); perft.MovesCount = InternalPerft(depth, 0); sw.Stop(); perft.Elapsed = (ulong)sw.ElapsedMilliseconds; return(perft); } else { prftMoves = new int[1000]; Stopwatch sw = new Stopwatch(); PerfResults perft = new PerfResults(); sw.Start(); perft.MovesCount = InternalPerftWithHash(depth, 0, perft, table); sw.Stop(); perft.Elapsed = (ulong)sw.ElapsedMilliseconds; return(perft); } }
public PerfResults Perf(out PerfResults undoRedo, int p) { throw new NotImplementedException(); }