Example #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Chess.NET by Gediminas Masaitis");
            IChessProtocol protocol    = null;
            var            interruptor = new ConsoleInterruptor();

            while (true)
            {
                string line;
                if (interruptor.IsRunning)
                {
                    line = interruptor.WaitStopAndGetResult();
                }
                else
                {
                    line = Console.ReadLine();
                }
                if (protocol == null && line == "uci")
                {
                    protocol           = new UCIProtocol(interruptor);
                    protocol.OnOutput += Console.WriteLine;
                    protocol.OnExit   += Environment.Exit;
                }
                protocol?.Input(line);
            }
        }
        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;

            Console.WriteLine("Chess.NET by Gediminas Masaitis");
            IChessProtocol protocol = null;

            while (true)
            {
                var line = Console.ReadLine();
                if (protocol == null && line == "uci")
                {
                    protocol           = new UciProtocol();
                    protocol.OnOutput += Console.WriteLine;
                    protocol.OnExit   += Environment.Exit;
                }
                protocol?.Input(line);
            }
        }
        private void Process(string input_message)
        {
            if (m_log.IsDebugEnabled)
            {
                m_log.Debug("GUI -> Engine: " + input_message);
            }

            var message = input_message.Trim();
            if (message.Length == 0)
            {
                return;
            }

            if (m_chess_protocol == null)
            {
                m_chess_protocol = CreateChessProtocol(message);
            }

            var commands = m_chess_protocol?.ProcessUiToEngineCommand(message);
            if (commands != null)
            {
                ExecuteCommands(commands);
            }
        }