예제 #1
0
        public Engine(string fileName, Coliseum coliseum, int processIndex, int gameIndex, int engineIndex, int numaNode, Dictionary <string, string> overriddenOptions)
        {
            this.Process.StartInfo.FileName = "cmd.exe";
            if (Path.IsPathRooted(fileName))
            {
                this.Process.StartInfo.WorkingDirectory = Path.GetDirectoryName(fileName);
            }
            this.Process.StartInfo.Arguments              = $"/c start /B /WAIT /NODE {numaNode} {fileName}";
            this.Process.StartInfo.UseShellExecute        = false;
            this.Process.StartInfo.RedirectStandardInput  = true;
            this.Process.StartInfo.RedirectStandardOutput = true;
            this.Process.StartInfo.RedirectStandardError  = true;
            this.Process.OutputDataReceived += HandleStdout;
            this.Process.ErrorDataReceived  += HandleStderr;
            this.Coliseum          = coliseum;
            this.ProcessIndex      = processIndex;
            this.GameIndex         = gameIndex;
            this.EngineIndex       = engineIndex;
            this.OverriddenOptions = overriddenOptions;

            // 同期的に実行した場合、
            // BeginOutputReadLine()/BeginErrorReadLine()が呼び出されたあと
            // 読み込みスレッドが動かない。
            // これを避けるため、Usi()やIsready()の内部でUsiAsync()やIsreadyAsync()を、
            // 非同期的に呼びだしている。
            Process.Start();
            Process.BeginOutputReadLine();
            Process.BeginErrorReadLine();
        }
예제 #2
0
        public void Run(Options options)
        {
            var coliseum = new Coliseum();

            coliseum.OnStatusChanged += ShowResult;
            coliseum.OnError         += OnError;
            coliseum.Run(options);
        }
예제 #3
0
        public async Task RunAsync(Options options)
        {
            string logFolderPath = Path.Combine(LogFolderName, Util.GetDateString());

            options.ToModel().Save(Path.Combine(logFolderPath, "setting.xml"));

            var coliseum = new Coliseum();

            coliseum.ShowStatus       += ShowStatus;
            coliseum.ShowErrorMessage += ShowErrorMessage;
            await coliseum.RunAsync(options, logFolderPath);
        }
예제 #4
0
 private void ShowStatus(Options options, Status status, Engine engine1, Engine engine2)
 {
     State.Value            = Coliseum.CreateStatusMessage(options, status, engine1, engine2);
     ProgressBarValue.Value = status.NumFinishedGames;
 }
예제 #5
0
        private async void OnStart()
        {
            // 測定開始前に設定を保存しておく
            model.Save(SettingFileName);

            var options = new Options
            {
                Engine1FilePath       = Engine1FilePath.Value,
                Engine2FilePath       = Engine2FilePath.Value,
                Eval1FolderPath       = Eval1FolderPath.Value,
                Eval2FolderPath       = Eval2FolderPath.Value,
                NumConcurrentGames    = NumConcurrentGames.Value,
                NumGames              = NumGames.Value,
                HashMb                = HashMb.Value,
                NumBookMoves1         = NumBookMoves1.Value,
                NumBookMoves2         = NumBookMoves2.Value,
                BookFileName1         = BookFileName1.Value,
                BookFileName2         = BookFileName2.Value,
                NumBookMoves          = NumBookMoves.Value,
                MaxMovesToDraw        = MaxMovesToDraw.Value,
                SfenFilePath          = SfenFilePath.Value,
                Nodes1                = Nodes1.Value,
                Nodes2                = Nodes2.Value,
                NodesRandomPercent1   = NodesRandomPercent1.Value,
                NodesRandomPercent2   = NodesRandomPercent2.Value,
                NodesRandomEveryMove1 = NodesRandomEveryMove1.Value,
                NodesRandomEveryMove2 = NodesRandomEveryMove2.Value,
                Time1                  = Time1.Value,
                Time2                  = Time2.Value,
                Byoyomi1               = Byoyomi1.Value,
                Byoyomi2               = Byoyomi2.Value,
                Inc1                   = Inc1.Value,
                Inc2                   = Inc2.Value,
                Rtime1                 = Rtime1.Value,
                Rtime2                 = Rtime2.Value,
                NumNumaNodes           = NumNumaNodes.Value,
                ProgressIntervalMs     = ProgressIntervalMs.Value,
                NumThreads1            = NumThreads1.Value,
                NumThreads2            = NumThreads2.Value,
                BookEvalDiff1          = BookEvalDiff1.Value,
                BookEvalDiff2          = BookEvalDiff2.Value,
                ConsiderBookMoveCount1 = ConsiderBookMoveCount1.Value,
                ConsiderBookMoveCount2 = ConsiderBookMoveCount2.Value,
                IgnoreBookPly1         = IgnoreBookPly1.Value,
                IgnoreBookPly2         = IgnoreBookPly2.Value,
                SlowMover1             = SlowMover1.Value,
                SlowMover2             = SlowMover2.Value,
                DrawValue1             = DrawValue1.Value,
                DrawValue2             = DrawValue2.Value,
                BookEvalBlackLimit1    = BookEvalBlackLimit1.Value,
                BookEvalBlackLimit2    = BookEvalBlackLimit2.Value,
                BookEvalWhiteLimit1    = BookEvalWhiteLimit1.Value,
                BookEvalWhiteLimit2    = BookEvalWhiteLimit2.Value,
                FVScale1               = FVScale1.Value,
                FVScale2               = FVScale2.Value,
                Gui = true,
            };

            ProgressBarValue.Value   = 0;
            ProgressBarMinimum.Value = 0;
            ProgressBarMaximum.Value = NumGames.Value;

            var coliseum = new Coliseum();

            coliseum.ShowStatus       += ShowStatus;
            coliseum.ShowErrorMessage += ShowErrorMessage;

            // logフォルダを作成する。
            string logFolderPath = Path.Combine(LogFolderName, Util.GetDateString());

            Directory.CreateDirectory(logFolderPath);

            // ログフォルダに設定ファイルを保存する。
            model.Save(Path.Combine(logFolderPath, "setting.xml"));

            StartMenuItemEnabled.Value = false;
            await coliseum.RunAsync(options, logFolderPath);

            StartMenuItemEnabled.Value = true;
        }
예제 #6
0
 private void ShowStatus(Options options, Status status, Engine engine1, Engine engine2)
 {
     Console.WriteLine(Coliseum.CreateStatusMessage(options, status, engine1, engine2));
     Console.Out.Flush();
 }