示例#1
0
        public void EvaluateBranch(int index, ISearchNode searchNode, InnerResult parentResult)
        {
            LogFile.Debug("{0} start eval move {1}", searchNode, index);

            // Create a snapshot, of the game before traversing
            // a branch.
            var snaphost = _game.CreateSnapshot();

            searchNode.SetResult(index);
            ParentResult = parentResult;
            ResultIndex  = index;

            // Traverse this branch, and build result subtree.
            _game.Simulate(_search.SearchUntilDepth);

            if (parentResult.HasChildrenWithIndex(index) == false)
            {
                // No children were added on this branch and the game has
                // finished or we have reached our intended depth.
                // Add a leaf node with game score.
                var leafResult = new LeafResult(_game.Score, SearchDepth);
                parentResult.AddChild(index, leafResult);
            }

            // Restore the game from the snapshot.
            _game.RollbackToSnapshot(snaphost);

            LogFile.Debug("{0} stop eval move {1}", searchNode, index);
        }
示例#2
0
        public void EvaluateBranch(int index, ISearchNode searchNode, InnerResult parentResult)
        {
            LogFile.Debug("{0} start eval move {1}", searchNode, index);

              // Create a snapshot, of the game before traversing
              // a branch.
              var snaphost = _game.CreateSnapshot();

              searchNode.SetResult(index);
              ParentResult = parentResult;
              ResultIndex = index;

              // Traverse this branch, and build result subtree.
              _game.Simulate(_search.SearchUntilDepth);

              if (parentResult.HasChildrenWithIndex(index) == false)
              {
            // No children were added on this branch and the game has
            // finished or we have reached our intended depth.
            // Add a leaf node with game score.
            var leafResult = new LeafResult(_game.Score, SearchDepth);
            parentResult.AddChild(index, leafResult);
              }

              // Restore the game from the snapshot.
              _game.RollbackToSnapshot(snaphost);

              LogFile.Debug("{0} stop eval move {1}", searchNode, index);
        }