Example #1
0
 private void CalculateRecursively(BoardStateNode currentNode)
 {
     ProcessNode(currentNode);
     foreach (var child in currentNode.Children)
     {
         CalculateRecursively(child);
     }
 }
Example #2
0
        private BoardStateNode CalculateOdds()
        {
            var rootCopy = new BoardStateNode
            {
                Value = _startingState
            };

            CalculateRecursively(rootCopy);

            return(rootCopy);
        }
Example #3
0
        private void ProcessNode(BoardStateNode currentNode)
        {
            if (currentNode.Value.IsLeaf)
            {
                _leaves.Add(currentNode.Value);
                return;
            }

            var possibilities     = ExecuteAttack(currentNode.Value);
            var possibilityChance = currentNode.Value.Probability / possibilities.Count;

            foreach (var possibility in possibilities)
            {
                possibility.Probability = possibilityChance;

                currentNode.Children.Add(new BoardStateNode
                {
                    Value  = possibility,
                    Parent = currentNode,
                });
            }
        }