Esempio n. 1
0
        private void InitEngines()
        {
            if (uciEngineWhite == null && File.Exists(Ap.EngineOptions.WhiteEngine))
            {
                uciEngineWhite = new UCIEngine(Ap.EngineOptions.WhiteEngine, Ap.EngineOptions.HashTableSize, this.Game);
                uciEngineWhite.UseTablebases = Ap.EngineOptions.UseTablebases;
                uciEngineWhite.Load();
                uciEngineWhite.Close();
            }
            if (uciEngineBlack == null && File.Exists(Ap.EngineOptions.BlackEngine))
            {
                uciEngineBlack = new UCIEngine(Ap.EngineOptions.BlackEngine, Ap.EngineOptions.HashTableSize, this.Game);
                uciEngineBlack.UseTablebases = Ap.EngineOptions.UseTablebases;
                uciEngineBlack.Load();
                uciEngineBlack.Close();
            }

            if (bookWhite == null && File.Exists(Ap.EngineOptions.WhiteBook))
            {
                bookWhite = new Book(this.Game, Ap.EngineOptions.WhiteBook);
                bookWhite.BookOptions.OptionsType = BookOptionsType.WhiteEngine;
                bookWhite.SetOptions();
            }

            if (bookBlack == null && File.Exists(Ap.EngineOptions.BlackBook))
            {
                bookBlack = new Book(this.Game, Ap.EngineOptions.BlackBook);
                bookBlack.BookOptions.OptionsType = BookOptionsType.BlackEngine;
                bookBlack.SetOptions();
            }
        }
Esempio n. 2
0
        private static void LoadUserEngine(Game game, int engineID, int chessTypeID, string bookFile)
        {
            DataSet dataset = SocketClient.GetSetIntruptedGameUserEngine(engineID, UserStatusE.Playing);

            if (dataset != null && dataset.Tables.Count > 0)
            {
                if (dataset.Tables[0] != null && dataset.Tables[0].Rows.Count > 0)
                {
                    App.Model.Db.Engine engine = new App.Model.Db.Engine(Ap.Cxt, dataset.Tables[0].Rows[0]);

                    InfinitySettings.EngineManager.EngineManager objEngineManager = new InfinitySettings.EngineManager.EngineManager();
                    List <InfinitySettings.EngineManager.Engine> lstEngine        = objEngineManager.LoadEngines();
                    InfinitySettings.EngineManager.Engine        eng = lstEngine.Where(x => x.IsActive == true && x.EngineTitle.Replace(".exe", "") == engine.Name).FirstOrDefault();

                    if (eng != null)
                    {
                        UCIEngine selectedEngine = new UCIEngine(eng.FilePath, Ap.EngineOptions.HashTableSize, game);

                        selectedEngine.Load();
                        selectedEngine.Close();

                        Ap.PlayingMode.SelectedEngine = selectedEngine;
                        Ap.PlayingMode.ChessTypeID    = chessTypeID;
                        Ap.PlayingMode.SelectedBook   = new Book(game, bookFile);
                    }
                }
            }
        }
Esempio n. 3
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (lstEngines.Items.Count > 0 && lstEngines.SelectedValue != null)
            {
                string engineFilePath = lstEngines.SelectedValue.ToString();
                int    hashTableSize  = (int)numHashTableSize.Value;

                if (selectedEngine != null)
                {
                    selectedEngine.Close();
                }

                selectedEngine = new UCIEngine(engineFilePath, hashTableSize, this.Game);
                if (engineParameters != null)
                {
                    engineParameters.SetEngineParameters(selectedEngine);
                }

                selectedEngine.UseTablebases = chkUseTablebases.Checked;
                selectedEngine.Load();
                selectedEngine.Close();

                if (selectedBook != null && selectedBook.BookOptions != null && selectedBook.BookOptions.UseBook)
                {
                    selectedBook.SetOptions(selectedBook.BookOptions);
                }
                else
                {
                    selectedBook = null;
                }

                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }
Esempio n. 4
0
        private void LoadNewEngine()
        {
            if (!IsNewEngineSelected)
            {
                return;
            }

            EngineManager objEngineManager = new EngineManager();

            objEngineManager.SaveDefaultEngine(lstEngines.SelectedValue.ToString());

            int hashTableSize = Convert.ToInt32(cmbHashTableSize.SelectedValue);

            InfinitySettings.Settings.DefaultEngineXml = objEngineManager.LoadDefaultEngine();
            string engineFile = InfinitySettings.Settings.DefaultEngineXml.FilePath;

            selectedEngine = new UCIEngine(engineFile, hashTableSize, this.Game);
            if (engineParameters != null)
            {
                engineParameters.SetEngineParameters(selectedEngine);
            }

            UCIEngine oldEngine = this.Game.DefaultEngine;

            if (oldEngine != null)
            {
                oldEngine.Close();
            }
            selectedEngine.UseTablebases = chkUseTablebases.Checked;
            selectedEngine.Load();
        }
 private void LoadEngine()
 {
     uciEngine = new UCIEngine(EngineFilePath, Options.DefaultHashTableSize, this.Game);
     uciEngine.OptionReceived += new UCIEngine.OptionReceivedHandler(uciEngine_OptionReceived);
     uciEngine.UciOkReceived  += new EventHandler(uciEngine_UciOkReceived);
     uciEngine.Load();
 }
Esempio n. 6
0
        private void AddKibitzer()
        {
            string    engineName    = lstEngines.SelectedValue.ToString();
            int       hashTableSize = Convert.ToInt32(cmbHashTableSize.SelectedValue);
            UCIEngine uciEngine     = new UCIEngine(engineName, hashTableSize, this.Game);

            uciEngine.IsKibitzer    = true;
            uciEngine.NameReceived += new UCIEngine.NameReceivedHandler(uciEngine_NameReceived);
            uciEngine.Load();
        }