GameTreeSearch.TreeSearch.FindMaxValue C# (CSharp) Method

FindMaxValue() public method

public FindMaxValue ( Tree tree, int depth ) : int
tree Tree
depth int
return int
        public int FindMaxValue(Tree tree, int depth)
        {
            if (depth > 0 && tree.ChildNodes.Count() > 0)
                return tree.ChildNodes.Max(tr => this.FindMaxValue(tr, depth - 1));

            return tree.RootValue;
        }

Usage Example

Exemplo n.º 1
0
        public void DepthZeroReturnRootNode()
        {
            Tree tree = CreateTree(3);
            TreeSearch search = new TreeSearch();

            Assert.AreEqual(3, search.FindMaxValue(tree, 0));
        }
All Usage Examples Of GameTreeSearch.TreeSearch::FindMaxValue
TreeSearch