Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="engineEXE"></param>
        /// <param name="engineExtraCommand"></param>
        /// <param name="runnerIndex">optional index of this runner within parallel set of runners</param>
        public UCIGameRunner(string engineEXE,
                             bool resetStateAndCachesBeforeMoves,
                             string extraCommandLineArguments = null,
                             string[] uciSetOptionCommands    = null,
                             int runnerIndex = -1)
        {
            EngineEXE = engineEXE;
            ResetStateAndCachesBeforeMoves = resetStateAndCachesBeforeMoves;
            EngineExtraCommand             = extraCommandLineArguments;
            Index = runnerIndex;

            ReadEvent readHandler = new ReadEvent(DataRead);

            string engine1Name = new FileInfo(engineEXE).Name;

            engine = StartEngine(engine1Name, engineEXE, extraCommandLineArguments, readHandler);

            System.Threading.Thread.Sleep(20);

            if (uciSetOptionCommands != null)
            {
                foreach (string extraCommand in uciSetOptionCommands)
                {
                    engine.SendCommandLine(extraCommand);
                }
            }

            freq      = Stopwatch.Frequency;
            startTime = Stopwatch.GetTimestamp();
        }
Пример #2
0
        /// <summary>
        /// Executes any preparatory UCI commands before sending a position for evaluation.
        /// These preparatory steps are typically not counted in the search time for the engine.
        /// </summary>
        /// <param name="engineNum"></param>
        public void EvalPositionPrepare()
        {
            if (ResetStateAndCachesBeforeMoves)
            {
                // Not all engines support Clear hash, e.g.
                // "option name Clear Hash type button"
                // so we do not issue this command.
                //thisEngine.SendCommandLine("setoption name Clear Hash");

                // Perhaps ucinewgame helps reset state
                engine.SendCommandLine("ucinewgame");
                engine.SendIsReadyAndWaitForOK();
            }

            havePrepared = true;
        }
Пример #3
0
 protected void SendCommandCRLF(UCIEngineProcess thisEngine, string cmd)
 {
     if (UCI_VERBOSE_LOGGING)
     {
         Console.WriteLine("--> CMD " + cmd);
     }
     thisEngine.SendCommandLine(cmd);
 }
Пример #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="exe"></param>
        /// <param name="extraCommand"></param>
        /// <param name="readHandler"></param>
        /// <param name="numThreads">N.B. when doing single static position evals from LC0, must set to 1</param>
        /// <returns></returns>
        UCIEngineProcess StartEngine(string engineName, string exePath, string extraCommand, ReadEvent readHandler, int numThreads = 1)
        {
            UCIEngineProcess engine = new UCIEngineProcess(engineName, exePath, extraCommand);

            engine.ReadEvent += readHandler;
            engine.StartEngine();

            engine.ReadAsync();

            engine.SendCommandLine("uci");
            engine.SendIsReadyAndWaitForOK();

            return(engine);
        }