< Summary

Information
Class: Rudim.Search.IterativeDeepening
Assembly: Rudim
File(s): /home/runner/work/rudim/rudim/Rudim/Search/IterativeDeepening.cs
Line coverage
95%
Covered lines: 19
Uncovered lines: 1
Coverable lines: 20
Total lines: 51
Line coverage: 95%
Branch coverage
83%
Covered branches: 5
Total branches: 6
Branch coverage: 83.3%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Search(...)83.33%6695%

File(s)

/home/runner/work/rudim/rudim/Rudim/Search/IterativeDeepening.cs

#LineLine coverage
 1using Rudim.Board;
 2using Rudim.CLI;
 3using Rudim.Common;
 4using System;
 5using System.Collections.Generic;
 6using System.Diagnostics;
 7using System.Linq;
 8using System.Threading;
 9
 10namespace Rudim.Search
 11{
 12    public static class IterativeDeepening
 13    {
 14        public static Move BestMove;
 15        public static int Score;
 16        public static int Nodes;
 17
 18        public static void Search(BoardState boardState, int depth, CancellationToken cancellationToken, ref bool debugM
 19        {
 520            Stopwatch timer = new Stopwatch();
 521            BestMove = Move.NoMove;
 522            Score = 0;
 523            Nodes = 0;
 9424            for (int i = 1; i <= depth; ++i)
 25            {
 4326                timer.Restart();
 4327                Score = Negamax.Search(boardState, i, cancellationToken);
 28
 4329                if (cancellationToken.IsCancellationRequested)
 30                    break;
 31
 4232                BestMove = boardState.BestMove;
 4233                int nodesTraversed = Negamax.Nodes + Quiescence.Nodes;
 4234                Nodes += nodesTraversed;
 35
 4236                timer.Stop();
 4237                double time = Math.Max(timer.ElapsedMilliseconds, 1);
 4238                int nps = (int)(Nodes / time * 1000);
 39
 4240                List<Move> pv = TranspositionTable.CollectPrincipalVariation(boardState);
 4241                string pvString = string.Join(' ', pv.Select(move =>
 14642                    move.Source.ToString() + move.Target.ToString() + move.GetPromotionChar()));
 43
 4244                if (debugMode)
 45                {
 046                    CliClient.WriteLine($"info depth {i} score cp {Score} nodes {nodesTraversed} time {time} nps {nps} p
 47                }
 48            }
 549        }
 50    }
 51}