Пример #1
0
        public void MtdfIds()
        {
            var ids = new MtdfIds()
            {
                Depth = Depth,
            };

            ids.Tt = ids.MakeTt(TtCapacity);
            ids.Search(State.Start);
        }
Пример #2
0
        static void Search(
            State root,
            MtdfIds searcher,
            GoSettings settings,
            Program program,
            CancellationToken ct)
        {
            ISearchInfo info;

            {
                using var _ = searcher.IterationCompleted.Subscribe(icInfo =>
                {
                    // todo: even if we have cached tt info, we should be outputting the full pv
                    // todo: output other info fields (see stockfish)
                    var output = $"info depth {icInfo.Depth} time {(int)icInfo.Elapsed.TotalMilliseconds} nodes {icInfo.NodesSearched} score cp {icInfo.Score} pv {string.Join(' ', icInfo.Pv)}";
                    WriteLine(output);
                });

                info = searcher.Search(root, ct);
            }

            // if we finished but we're in ponder or infinite mode, wait until we receive "ponderhit" or "stop"

            while (!ct.IsCancellationRequested && (settings.Infinite || program._ponder))
            {
                Thread.Sleep(500);
            }

            // output the best move. if the pv contains more than 1 move (eg. there's not a mate in 1 and we searched more than depth 1),
            // output that too as the next move we expect the user to play.

            Debug.Assert(!info.Pv.IsEmpty);
            var output = $"bestmove {info.Pv[0]}";

            if (info.Pv.Length > 1)
            {
                output += $" ponder {info.Pv[1]}";
            }
            WriteLine(output);
        }