예제 #1
0
        private void StartStopSearchButton_Click(object sender, EventArgs e)
        {
            PushToSettings();

            if (SearchSettings.BadSettings())
            {
                MessageBox.Show("Ошибка! \nНужно задать корневую директорию и хотя бы один фильтр, и их длина должна быть не больше 50 символов.");
                return;
            }

            SearchStarted = !SearchStarted;

            if (SearchStarted)
            {
                DisableConfig();
                PauseResumeSearchButton.Enabled = true;
                StartStopSearchButton.Text      = "Stop";
                BackgroundSearcher.RunWorkerAsync();
                SearchTimer.Start();
            }
            else
            {
                BackgroundSearcher.CancelAsync();
                SearchPaused = false;
                EnableConfig();
                PauseResumeSearchButton.Text    = "Pause";
                PauseResumeSearchButton.Enabled = false;
                SearchTimer.Stop();
            }
        }
예제 #2
0
 /// <summary>
 /// Input on the search box changed,
 /// start searchTimer to validate and search.
 /// </summary>
 private void searchBox_TextChanged(object sender, TextChangedEventArgs e)
 {
     // No need to search if there is no data
     if (ViewModel.Collections.Count > 0)
     {
         SearchTimer.Stop();
         SearchTimer.Start();
     }
 }
예제 #3
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            if (!IsWindows10())
            {
                this.Close();
            }

            SearchTimer.Start();
            SearchTimer.Interval = 10;
        }
예제 #4
0
        private void PauseResumeSearchButton_Click(object sender, EventArgs e)
        {
            SearchPaused = !SearchPaused;

            if (SearchPaused)
            {
                _busy.Reset();
                PauseResumeSearchButton.Text = "Resume";
                SearchTimer.Stop();
            }
            else
            {
                PauseResumeSearchButton.Text = "Pause";
                _busy.Set();
                SearchTimer.Start();
            }

            SearchSettings.SaveSettingsToConfig();
        }
 private void SearchButton_Click(object sender, EventArgs e)
 {
     SearchTimer.Start();
 }
예제 #6
0
        protected List <Move>?startSearch(Position?position, SearchMode mode)
        {
            try {
                if (position is null)
                {
                    throw new PositionException("Null Position");
                }
                else if (SearchTimer is null)
                {
                    throw new PositionException("Null SearchTimer Stopwatch");
                }
                else
                {
                    SearchTimer.Reset();
                    IntervalNodes      =
                        HeartbeatNodes = (UInt64)NodeTotal;
                    LastBeatMS         = SearchTimer.ElapsedMilliseconds;
                }

                if (position.IsLegal())
                {
                    StartDepth = 0;     //[Init]
                    ClearSearchCounts();

                    if (UCI.IsDebug)
                    {
                        var dtStarted = DateTime.Now;
#if Herald
                        herald(dtStarted, position.Name);
#endif
#if NoteStartAndFinish
                        LogInfo(Level.note, $"Started at {dtStarted:yyyy-MM-dd HH:mm:ss.ff}");
#endif
                    }

                    SearchTimer.Start();

                    switch (mode)
                    {
                    case SearchMode.BestMove:
                        var mValue = position.IteratePlies(Bound);
                        break;

                    case SearchMode.Perft:
                        position.IterateCases();
                        break;
                    }
                }
                else
                {
                    throw new PositionException("Illegal Setup");
                }
            }
            catch (OperationCanceledException) {
                //
                // OperationCanceledException is thrown in MonitorBound() via ThrowIfCancellationRequested(),
                // when Cancel() has been called on the source of this Task's CancellationToken.  Catching
                // it here allows stack frames for an active search to return Position objects to the pool.
                //
            }
            catch (FinalPositionException ex) {
                LogInfo(Level.note, ex.Message);
            }
            catch (ApplicationException ex) {
#if StackTrace
                LogInfo(Level.error, ex.ToString());
#else
                LogInfo(Level.error, ex.Message);
#endif
            }
            catch (Exception ex) {
                LogInfo(Level.error, ex.ToString());
            }
            finally {
                if (SearchTimer.IsRunning)
                {
                    SearchTimer.Stop();
                }

                if (UCI.IsDebug)
                {
                    LogInfoNewLine(Level.note);
#if NoteStartAndFinish
                    LogInfo(Level.note, $"Finished at {DateTime.Now:yyyy-MM-dd HH:mm:ss.ff}");
#endif
                    var dElapsedMS = (Double)SearchTimer.ElapsedMilliseconds;
                    displayCounts(mode, dElapsedMS);
                }
            }

            //
            //[Optional]Repeat final bestmove report:
            //
            if (BestMoves is not null)
            {
                var sb = new StringBuilder();
                //[Note]refreshPV() has been called
                sb.BestMove(BestMoves, Rule);
                if (sb.Length > 0)
                {
                    LogLine(sb.ToString());
                }
            }

            return(BestMoves);
        }