当前位置: 首页>>代码示例>>C++>>正文


C++ TreeNode::GetNumberOfChildren方法代码示例

本文整理汇总了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;
	}
}
开发者ID:ipidev,项目名称:RamAi,代码行数:33,代码来源:GameMonteCarloTree.cpp

示例2: PartialExpansion

bool RamAi::GameMonteCarloTree::NodeNeedsExpanding(const TreeNode &node) const
{
	return (node.GetNumberOfChildren() < ConsoleSettings::GetSpecs().GetNumberOfInputCombinations()) && PartialExpansion(node);
}
开发者ID:ipidev,项目名称:RamAi,代码行数:4,代码来源:GameMonteCarloTree.cpp


注:本文中的TreeNode::GetNumberOfChildren方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。