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(); } }
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(); } }
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); } } } }
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 btnOK_Click(object sender, EventArgs e) { if (Ap.IsGameInProgress) { PlayingModeData.Instance.AutometicChallenges = chkAutomaticChallenges.Checked; PlayingModeData.Instance.AutometicAccepts = chkAutometicAccepts.Checked; this.Close(); } else { string engineName = string.Empty; UserStatusE userStatus; if (rbHuman.Checked) { if (selectedEngine != null) { selectedEngine.Close(); selectedEngine = null; } Ap.PlayingMode.ChessTypeID = 1; PlayingModeData.Instance.AutometicChallenges = false; PlayingModeData.Instance.AutometicAccepts = false; PlayingModeData.Instance.SendEvaluations = false; PlayingModeData.Instance.SendExpectedMoves = false; userStatus = UserStatusE.Blank; } else if (rbComputer.Checked) { if (selectedEngine == null) { MessageForm.Show(this, MsgE.InfoUploadEngine); return; } engineName = selectedEngine.EngineName; Ap.PlayingMode.ChessTypeID = 2; PlayingModeData.Instance.AutometicChallenges = chkAutomaticChallenges.Checked; PlayingModeData.Instance.AutometicAccepts = chkAutometicAccepts.Checked; PlayingModeData.Instance.SendEvaluations = chkSendEvaluations.Checked; PlayingModeData.Instance.SendExpectedMoves = chkSendExpectedMove.Checked; PlayingModeData.Instance.Time = UData.ToInt32(numericUpDown1.Value); PlayingModeData.Instance.GainPerMove = UData.ToInt32(numericUpDown2.Value); Ap.CurrentUser.UserStatusIDE = userStatus = UserStatusE.Engine; ChatClient.Write(ChatTypeE.OnlineClient, ChatMessageTypeE.Info, ChatTypeE.OnlineClient, "'" + engineName + "' loaded successfully", 0); } else { Ap.PlayingMode.ChessTypeID = 3; PlayingModeData.Instance.AutometicChallenges = false; PlayingModeData.Instance.AutometicAccepts = false; PlayingModeData.Instance.SendEvaluations = false; PlayingModeData.Instance.SendExpectedMoves = false; Ap.CurrentUser.UserStatusIDE = userStatus = UserStatusE.Centaur; } SocketClient.SetUserEngine(engineName, userStatus); PlayingModeData.Instance.Pause = Ap.CurrentUser.IsPause; PlayingModeData.Instance.ChessTypeID = Ap.PlayingMode.ChessTypeID; PlayingModeData.Instance.Save(); Ap.PlayingMode.SelectedEngine = selectedEngine; Ap.PlayingMode.SelectedBook = selectedBook; this.Close(); } }