本文整理汇总了C++中TreeNode::TraceDown方法的典型用法代码示例。如果您正苦于以下问题:C++ TreeNode::TraceDown方法的具体用法?C++ TreeNode::TraceDown怎么用?C++ TreeNode::TraceDown使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TreeNode
的用法示例。
在下文中一共展示了TreeNode::TraceDown方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
TreeNode *BStar::GetBestOptPrb(TreeNode *parent)
{
double MaxValue = 0.0;
double PrbD = 0.0;
TreeNode *aux = 0;
TreeNode *Sel = 0;
int DPV = 0; // depth PV
int DOpt = 0;
for(aux = parent->SelectBestReal();aux; aux = aux->SelectBestReal())
{
DPV++;
}
double np = parent->SubtreeSize;
const double Cucb = 2.0; //0.0000001; //2000.0;
for(aux = parent->MoveTo(FIRSTCHILD);
aux; aux = aux->MoveTo(NEXTSIBBLING))
{
PrbD = aux->OptPrb ;
if( PrbD > MaxValue )
{
MaxValue = PrbD;
Sel = aux ;
}
}
// PV can not be shorter than opt path
if(Sel == NULL) Sel = parent->SelectBestReal();
aux = Sel->TraceDown(1);
for(;aux && aux != TreeNode::GetRootNode(); aux = aux->MoveTo(PARENT))
DOpt++;
if(DOpt > DPV)
return parent->SelectBestReal();
return Sel;
}
示例2: Search
void BStar::Search()
{
int Cancelar = 0;
int i,NExpandFD = 0;
int LastIteration = -1;
Cancelar = 0;
DumpTree *dt;
TreeNode *CurNode = NULL; // last move expanded
TreeNode *CurBestNode = NULL; // last best
if(DumpData)
{
dt = new DumpTree();
}
TreeNode *a = NULL;
TreeNode *SelectedNode = NULL;
ColorRoot = TreeNode::GetRootNode()->Color;
NExpandFD = 18;
for(i=1;i < FixedDepth;i++)
{
NExpandFD *= 3; // Branch factor 3
}
if(FixedDepth)
{
SelectNodes = (NExpandFD * 6)/10;
VerifyNodes = NExpandFD - SelectNodes;
}
for(;;)
{
if(LastIteration == TotalExpand)
break; // avoid cicle without expands.
LastIteration = TotalExpand;
if(Cancel||Cancelar)
break;
// printf("SELECT Step %d\n",TotalExpand);
while (GetRealValBestAtRoot() <= OptValAnyOtherMoveAtRoot())
{
if(BestMoveAtRoot != CurBestNode)
{
if(CurBestNode != NULL)
PrintPV();
CurBestNode = BestMoveAtRoot;
LastChange = TotalExpand;
PrintPV();
}
if(TreeNode::GetRootNode()->RealVal > (MATE-50)
|| TreeNode::GetRootNode()->RealVal < (50-MATE)
)
{
Cancelar= 1;
// switch to verify
break;
}
TargetVal = ((BestMoveAtRoot->RealVal) + OptVal2ndBest)/2;
// it is unlikely that any other move can achieve as good a RealVal ?
if( SecondRootOptPrb() < MinAct)
{
if(GetRealValBestAtRoot() >= (RealVal2ndBstMoveAtRoot() + 1))
// goto salida;
break;
}
if(DumpData )
{
dt->Print("SELECT STEP Color %d Best %d Target Value %d\n",ColorRoot,BestMoveAtRoot->RealVal,TargetVal);
dt->Write();
}
// Select Root Node with greatest OptPrb;
a = GetBestOptPrb(TreeNode::GetRootNode());
if(!a)
break;
if(a != CurNode)
{
CurNode = a;
}
// Trace down the child subtree selecting
// For Player-to-Move nodes, child with largest OptPrb
// For Opponent-to-Move nodes, child with best RealVal
// Until arriving at a leaf node;
SelectedNode = a->TraceDownNotStopper(true);
if(DumpData)
{
dt->Print("Selected node:");
dt->DumpPath(SelectedNode,TreeNode::GetRootNode());
dt->Print("Color root %d\n",TreeNode::GetRootNode()->Color);
dt->DumpRoot();
}
if(SelectedNode->MoveCount != 0) // already expanded, mate pos?
{
break;
}
// Get RealVal for each Child Node of this leaf;
// If it is a Player-to-Move node get OptVals for each Child;
if(Cancelar||Cancel)
break;
Expand(SelectedNode,PLAYER);
//.........这里部分代码省略.........