Beispiel #1
0
        private void QueueNextGame()
        {
            if (MatchRunner != null)
            {
                MatchRunner.Dispose();
            }

            var nextGame = MasterState.Instance.DequeueMatch();

            if (nextGame == null)
            {
                Log.InfoDialog("No games are scheduled");
                return;
            }

            whitePlayerLog = new List <string>();
            blackPlayerLog = new List <string>();

            var whiteSettings = MasterState.Instance.Engines.SingleOrDefault(x => x.Id == nextGame.WhiteId);
            var blackSettings = MasterState.Instance.Engines.SingleOrDefault(x => x.Id == nextGame.BlackId);
            var timeSettings  = MasterState.Instance.TimeSettings.SingleOrDefault(x => x.Id == nextGame.TimeControlId);
            var white         = new UciEnginePlayer(whiteSettings);
            var black         = new UciEnginePlayer(blackSettings);

            MatchRunner = new MatchRunner(white, black, timeSettings);

            MatchRunner.PlayerWhite.RegisterCommandListener((d, msg) =>
            {
                var str = string.Format("White {0}: {1}", d == UciProcess.CommandDirection.EngineInput ? "Input" : "Output", msg);
                lock (whitePlayerLog)
                    whitePlayerLog.Add(str);
                NotifyChanged(() => WhitePlayerLog);
            });

            MatchRunner.PlayerBlack.RegisterCommandListener((d, msg) =>
            {
                var str = string.Format("Black {0}: {1}", d == UciProcess.CommandDirection.EngineInput ? "Input" : "Output", msg);
                lock (blackPlayerLog)
                    blackPlayerLog.Add(str);
                NotifyChanged(() => BlackPlayerLog);
            });

            MatchRunner.PlayerWhite.RegisterInfoListener(dict =>
            {
                UpdatePlayerInfo(dict, whitePlayerInfo);
                NotifyChanged(() => WhitePlayerInfo);
            });

            MatchRunner.PlayerBlack.RegisterInfoListener(dict =>
            {
                UpdatePlayerInfo(dict, blackPlayerInfo);
                NotifyChanged(() => BlackPlayerInfo);
            });

            NotifyChanged(() => MatchRunner);
            Task.Run(() => MatchRunner.LoadAndSetup());
        }
Beispiel #2
0
        public void TestMatchRunner1()
        {
            var config = new UciEngineSettings
            {
                Name    = "Rybka",
                Command = @"C:\chess\arena_3.0\Engines\Rybka\Rybka v2.2n2.mp.w32.exe"
            };

            var white        = new UciEnginePlayer(config);
            var black        = new UciEnginePlayer(config);
            var timeSettings = new TimeSettings {
                Name = "60 Sec Match", InitialTime = 60, TimeModeMachine = TimeMode.Blitz
            };
            var runner = new MatchRunner(white, black, timeSettings);

            runner.LoadAndSetup();
        }
Beispiel #3
0
        private void QueueNextGame()
        {
            if (MatchRunner != null)
            {
                MatchRunner.Dispose();
            }

            var nextGame = MasterState.Instance.DequeueMatch();
            if (nextGame == null)
            {
                Log.InfoDialog("No games are scheduled");
                return;
            }

            whitePlayerLog = new List<string>();
            blackPlayerLog = new List<string>();

            var whiteSettings = MasterState.Instance.Engines.SingleOrDefault(x => x.Id == nextGame.WhiteId);
            var blackSettings = MasterState.Instance.Engines.SingleOrDefault(x => x.Id == nextGame.BlackId);
            var timeSettings = MasterState.Instance.TimeSettings.SingleOrDefault(x => x.Id == nextGame.TimeControlId);
            var white = new UciEnginePlayer(whiteSettings);
            var black = new UciEnginePlayer(blackSettings);

            MatchRunner = new MatchRunner(white, black, timeSettings);

            MatchRunner.PlayerWhite.RegisterCommandListener((d, msg) =>
            {
                var str = string.Format("White {0}: {1}", d == UciProcess.CommandDirection.EngineInput ? "Input" : "Output", msg);
                lock (whitePlayerLog)
                    whitePlayerLog.Add(str);
                NotifyChanged(() => WhitePlayerLog);
            });

            MatchRunner.PlayerBlack.RegisterCommandListener((d, msg) =>
            {
                var str = string.Format("Black {0}: {1}", d == UciProcess.CommandDirection.EngineInput ? "Input" : "Output", msg);
                lock (blackPlayerLog)
                    blackPlayerLog.Add(str);
                NotifyChanged(() => BlackPlayerLog);
            });

            MatchRunner.PlayerWhite.RegisterInfoListener(dict =>
            {
                UpdatePlayerInfo(dict, whitePlayerInfo);
                NotifyChanged(() => WhitePlayerInfo);
            });

            MatchRunner.PlayerBlack.RegisterInfoListener(dict =>
            {
                UpdatePlayerInfo(dict, blackPlayerInfo);
                NotifyChanged(() => BlackPlayerInfo);
            });

            NotifyChanged(() => MatchRunner);
            Task.Run(() => MatchRunner.LoadAndSetup());
        }