Ejemplo n.º 1
0
        //	The playerReady event is raised once the engine process has started and
        //	the initial protocol handshake has been completed.  At this point the
        //	Engine object has learned about the engine's features by interrogating it
        //	so we can store them in the EngineConfiguration.
        protected void playerReady(Player player)
        {
            XBoardEngine engine = (XBoardEngine)player;

            currentConfiguration.InternalName      = engine.Name;
            currentConfiguration.FriendlyName      = engine.Name;
            currentConfiguration.SupportedFeatures = engine.SupportedFeatures;
            currentConfiguration.SupportedVariants = engine.Variants;
            RegistryKey engineFolderKey = enginesKey.OpenSubKey(currentConfiguration.FolderName, true);
            RegistryKey engineKey       = null;

            if (engineFolderKey == null)
            {
                //	This is the first engine discovered in this folder - create the folder
                //	key and place the engine in subkey "1"
                engineFolderKey = enginesKey.CreateSubKey(currentConfiguration.FolderName);
                engineKey       = engineFolderKey.CreateSubKey("1");
            }
            else
            {
                //	We have previously discovered engines in this folder - create a folder
                //	with the next available integer
                string[] subKeyNames  = engineFolderKey.GetSubKeyNames();
                int      engineNumber = 1;
                while (true)
                {
                    bool found = false;
                    foreach (string subKey in subKeyNames)
                    {
                        if (subKey == engineNumber.ToString())
                        {
                            found = true;
                        }
                    }
                    if (found)
                    {
                        engineNumber++;
                    }
                    else
                    {
                        break;
                    }
                }
                engineKey = engineFolderKey.CreateSubKey(engineNumber.ToString());
            }
            //	Save the information for this engine to the newly created registry key
            currentConfiguration.RegistryKey = engineKey;
            currentConfiguration.SaveToRegistry();
            engines.Add(currentConfiguration);

            if (engineDirList.Count > 0)
            {
                timer.Start();
            }
        }
Ejemplo n.º 2
0
        public void ManualEngineDiscover(string workingDirectory, string executable, List <string> arguments)
        {
            EngineConfiguration configuration = new EngineConfiguration("Manual", executable, "xboard");

            configuration.WorkingDirectory = workingDirectory;
            currentConfiguration           = configuration;
            if (arguments != null)
            {
                foreach (string arg in arguments)
                {
                    configuration.AddArgument(arg);
                }
            }
            DebugMessageLog log          = new DebugMessageLog();
            EngineBuilder   builder      = new EngineBuilder(log, configuration);
            TimerFactory    timerFactory = new TimerFactory();
            XBoardEngine    engine       = (XBoardEngine)builder.Create(timerFactory, playerReady);
        }
Ejemplo n.º 3
0
        protected void discoverExecutable(string engineDir, string executable)
        {
            string folderName = engineDir.Substring(engineDir.LastIndexOf(Path.DirectorySeparatorChar) + 1);
            //	fire it up to see what variants/features it supports
            EngineConfiguration configuration = new EngineConfiguration(folderName, executable, "xboard");

            configuration.WorkingDirectory = engineDir;
            //	if this directory contains a file named 'variants.txt' we will
            //	automatically pass that in as a command line argument (Sjaak II)
            if (File.Exists(engineDir + @"\variants.txt"))
            {
                configuration.AddArgument("variants.txt");
            }
            currentConfiguration = configuration;
            DebugMessageLog log          = new DebugMessageLog();
            EngineBuilder   builder      = new EngineBuilder(log, configuration);
            TimerFactory    timerFactory = new TimerFactory();
            XBoardEngine    engine       = (XBoardEngine)builder.Create(timerFactory, playerReady);
        }