public PhutballMoveScore Search(IFieldsGraph fieldsGraph)
 {
     var graphCopy = (IFieldsGraph)fieldsGraph.Clone();
     var tree = _movesFactory.GetMovesTree(graphCopy);
     var targetBorder = _playersState.CurrentPlayer.GetTargetBorder(fieldsGraph);
     var performMoves = new PerformMoves(graphCopy, _playersState);
     var bestValuePicker = new PickBestValueNodeVisitor(targetBorder, graphCopy, performMoves);
     var nodeCounter = new VisitedNodesCounter<JumpNode>();
     var depthCounter = new DepthCounterNodeVisitor<JumpNode>();
     var searchNodeVisitor = _defaultNodeVistor.FollowedBy(bestValuePicker).FollowedBy(nodeCounter).FollowedBy(depthCounter);
     var search = _searchFactory(searchNodeVisitor, performMoves, targetBorder);
     search.Run(tree);
     return new PhutballMoveScore( bestValuePicker.ResultMove, bestValuePicker.CurrentMaxValue)
                {
                    VisitedNodesCount = nodeCounter.Count,
                    MaxDepth = depthCounter.MaxDepth
                };
 }
Beispiel #2
0
        public PhutballMoveScore Search(IFieldsGraph fieldsGraph)
        {
            var graphCopy         = (IFieldsGraph)fieldsGraph.Clone();
            var tree              = _movesFactory.GetMovesTree(graphCopy);
            var targetBorder      = _playersState.CurrentPlayer.GetTargetBorder(fieldsGraph);
            var performMoves      = new PerformMoves(graphCopy, _playersState);
            var bestValuePicker   = new PickBestValueNodeVisitor(targetBorder, graphCopy, performMoves);
            var nodeCounter       = new VisitedNodesCounter <JumpNode>();
            var depthCounter      = new DepthCounterNodeVisitor <JumpNode>();
            var searchNodeVisitor = _defaultNodeVistor.FollowedBy(bestValuePicker).FollowedBy(nodeCounter).FollowedBy(depthCounter);
            var search            = _searchFactory(searchNodeVisitor, performMoves, targetBorder);

            search.Run(tree);
            return(new PhutballMoveScore(bestValuePicker.ResultMove, bestValuePicker.CurrentMaxValue)
            {
                VisitedNodesCount = nodeCounter.Count,
                MaxDepth = depthCounter.MaxDepth
            });
        }