public void OpeningD5_4865609() { int nodes = _perft.GoPerft(_openingPosition, 5); if (nodes != 4865609) { throw new Exception($"Result {nodes} needs to match method name {nameof(OpeningD5_4865609)}"); } }
private static void PerformanceTesting(string fen, int perftDepth, TimeSpan timespan) { var position = BoardParsing.PositionFromFen(fen); Debugging.Dump(position); var moveGen = new MoveGenerator(); var perft = new Perft(moveGen); Stopwatch overallStopwatch = new Stopwatch(); overallStopwatch.Start(); while (true) { int perftNum = perftDepth; Console.Write($"Perft {perftNum}: "); Stopwatch sw = new Stopwatch(); sw.Start(); int perftResults = perft.GoPerft(position, perftNum); sw.Stop(); double knps = ((double)perftResults) / sw.ElapsedMilliseconds; // it just works out Console.WriteLine($"{perftResults} ({knps:F2} knps)"); if (overallStopwatch.Elapsed > timespan) { break; } } //perft.GoPerft(position, perftDepth); }
private static void IncrementalPerft(string fen, int maxDepth) { var position = BoardParsing.PositionFromFen(fen); Debugging.Dump(position); var moveGen = new MoveGenerator(); var perft = new Perft(moveGen); for (int i = 1; i <= maxDepth; i++) { Console.Write($"Perft {i}: "); Stopwatch sw = new Stopwatch(); sw.Start(); int perftResults = perft.GoPerft(position, i); sw.Stop(); double knps = ((double)perftResults) / sw.ElapsedMilliseconds; // it just works out Console.WriteLine($"{perftResults} ({knps:F2} knps)"); } }
private static void GoDivide(MoveGenerator moveGenerator, Perft perft, Position position, int depth) { if (depth <= 0) { Console.WriteLine($"##### No moves generated at depth {depth}"); return; } var total = 0; List <Move> moves = new List <Move>(); moveGenerator.Generate(moves, position); var movesDict = new SortedDictionary <string, Move>(); foreach (var move in moves) { movesDict.Add(BoardParsing.CoordinateStringFromMove(move), move); } foreach (var(moveStr, move) in movesDict) { var nextBoard = Position.MakeMove(new Position(), move, position); // check move legality if using a pseudolegal move generator if (!moveGenerator.OnlyLegalMoves && nextBoard.MovedIntoCheck()) { continue; } Console.Write($"{moveStr}: "); int count = perft.GoPerft(nextBoard, depth - 1); Console.WriteLine(count); total += count; } Console.WriteLine($"##### Total moves: {total}"); }
public int PerftWithHashingTest(string fen, int depth) { var position = BoardParsing.PositionFromFen(fen); return(_perftWithHashing.GoPerft(position, depth)); }