예제 #1
0
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
0
void BStar::PrintPV()
{
	if(!PrintPVV)return;
	int timeUsed;
	char Path[1024];
	int SelDepth = 0;
	TreeNode *aux;
	Path[0] = '\0';
	for(aux = TreeNode::GetRootNode()->SelectBestReal();aux; aux = aux->SelectBestReal())
	{
		strcat(Path,aux->MoveStr);
		strcat(Path," ");
		SelDepth++;
		if(SelDepth > 20) break; // avoid buffer overrun on Path
	}

	timeUsed = TimeElapsed()-ini;
	if(timeUsed <=0)
		timeUsed = 1;
	int nps;
	nps = (TotalExpand * 1000)/ timeUsed;
	int mate;

	int value =  BestMoveAtRoot->RealVal;

	mate = 0;
	if(value >= MATE -50)
	{
		mate = MATE -value;
	}
	if(value <= -MATE +50)
	{
		mate = MATE +value;
		mate = -mate;
	}
	if(!mate)
	{
		Print("info depth %d seldepth %d pv %s score cp %d nodes %d nps %d hashfull %d time %ld\n",
			SelDepth,
			SelDepth,
			Path,
			value,
			TotalExpand ,
			//TotalNodes, //TotalExpand ,
			nps,
			0,	
			timeUsed);
	}
	else
	{
		Print("info depth %d seldepth %d pv %s score mate %d nodes %d nps %d hashfull %d time %ld\n",
			SelDepth,
			SelDepth,
			Path,
			mate/2,
			TotalExpand ,
			//TotalNodes, //TotalExpand ,
			nps,
			0,	
			timeUsed);
	}
}