Example #1
0
        private int StartNewSearch(ISearchNode searchNode, SearchResults cachedResults)
        {
            AdjustPerformance();
            ClearResultCache();

            var parameters = new SearchParameters(CurrentDepth, CurrentTargetCount,
                                                  _searchParameters.SearchPartitioningStrategy);

            CurrentSearch = new Search(parameters,
                                       searchNode.Controller, cachedResults, _game);

            SearchStarted(this, EventArgs.Empty);

            _game.Publish(new SearchStartedEvent(_searchParameters));
            _nodeCount = 0;

            using (new SearchMonitor(this))
            {
                LastSearchStatistics = CurrentSearch.Start(searchNode);
            }

            var result = CurrentSearch.Result;

            LastSearchStatistics.NodeCount = _nodeCount;
            UpdateSearchDurations();

            _game.Publish(new SearchFinishedEvent());
            SearchFinished(this, EventArgs.Empty);

            CurrentSearch = null;
            return(result);
        }
Example #2
0
    private int StartNewSearch(ISearchNode searchNode, SearchResults cachedResults)
    {
      AdjustPerformance();
      ClearResultCache();

      var parameters = new SearchParameters(CurrentDepth, CurrentTargetCount,
        _searchParameters.SearchPartitioningStrategy);

      CurrentSearch = new Search(parameters,
        searchNode.Controller, cachedResults, _game);

      SearchStarted(this, EventArgs.Empty);

      _game.Publish(new SearchStartedEvent(_searchParameters));
      _nodeCount = 0;

      using (new SearchMonitor(this))
      {
        LastSearchStatistics = CurrentSearch.Start(searchNode);
      }

      var result = CurrentSearch.Result;

      LastSearchStatistics.NodeCount = _nodeCount;
      UpdateSearchDurations();

      _game.Publish(new SearchFinishedEvent());
      SearchFinished(this, EventArgs.Empty);

      CurrentSearch = null;
      return result;
    }