Esempio n. 1
0
        public SearchStatistics Start(ISearchNode searchNode)
        {
            _stopwatch.Start();

            // Lock original changer tracker.
            // So we are sure that original game state stays intact.
            // This is usefull for debuging state copy issues.
            _game.ChangeTracker.Lock();

            // Both original and copied tracker will be enabled,
            // but only the copy is unlocked and can track state.
            _game.ChangeTracker.Enable();


            // Copy game state,
            var searchNodeCopy = new CopyService().CopyRoot(searchNode);

            // create the first worker
            var worker = CreateWorker(_root, searchNodeCopy.Game);

            // and start the search.
            worker.StartSearch(searchNodeCopy);

            RemoveWorker(worker);

            _game.ChangeTracker.Disable();
            _game.ChangeTracker.Unlock();

            _root.EvaluateSubtree();
            _stopwatch.Stop();

            return(GetSearchStatistics());
        }