本文整理汇总了C++中TreeNode::GetNumberOfChildren方法的典型用法代码示例。如果您正苦于以下问题:C++ TreeNode::GetNumberOfChildren方法的具体用法?C++ TreeNode::GetNumberOfChildren怎么用?C++ TreeNode::GetNumberOfChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TreeNode
的用法示例。
在下文中一共展示了TreeNode::GetNumberOfChildren方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sqrt
bool RamAi::GameMonteCarloTree::PartialExpansion(const TreeNode &parent) const
{
//From http://julian.togelius.com/Jacobsen2014Monte.pdf
if (!parent.IsLeaf())
{
const double numberOfChildren = static_cast<double>(parent.GetNumberOfChildren());
const double numberOfVisits = static_cast<double>(parent.GetScore().GetVisits());
const double expansionWeighting = sqrt((2.0 * log(numberOfVisits)) / (1.0 + numberOfChildren));
const double expansionWeightingWithBias = GetBias() * expansionWeighting;
const double unexpandedNodesValue = AiSettings::GetData().partialExpansionBase;
const double expansionUrgencyScore = unexpandedNodesValue + expansionWeightingWithBias;
//Check the expansion urgency score of the parent node with each of its children.
//If the expansion urgency is greater than the confidence of any of its children, then the node is expanded (returns true).
for (auto it = parent.GetIteratorBegin(); it != parent.GetIteratorEnd(); ++it)
{
const double uctScore = CalculateUcbScore(parent, it->second);
if (expansionUrgencyScore > uctScore)
{
return true;
}
}
return false;
}
else
{
return true;
}
}
示例2: PartialExpansion
bool RamAi::GameMonteCarloTree::NodeNeedsExpanding(const TreeNode &node) const
{
return (node.GetNumberOfChildren() < ConsoleSettings::GetSpecs().GetNumberOfInputCombinations()) && PartialExpansion(node);
}