コード例 #1
0
IBAction* IBActionLibrary::FindActionDef(IBFact* pFact)
{
	ActionDefMap::iterator begin = m_oMap.begin();
	ActionDefMap::iterator end = m_oMap.end();
	ActionDefMap::iterator it;

	//IBAction* pBestAction = NULL;
	//float fBestValuate;

	for (it=begin ; it!=end ; ++it)
	{
		IBActionDef* pActionDef = it->second;

		for (uint i=0 ; i< pActionDef->GetPostCondDef().size() ; ++i)
		{
			IBFactDef* pFactDef = pActionDef->GetPostCondDef()[i].m_pFactDef;
			if (pFactDef->GetName() == pFact->GetFactDef()->GetName())
			{
				IBAction* pAction = pActionDef->Instanciate(pFact);

				/*
				float fValue = pAction->Evaluate();

				if (pBestAction == NULL)
				{
					pBestAction = pAction;
					fBestValuate = fValue;
				}
				else if (fValue > fBestValuate)
				{
					delete pBestAction;
					pBestAction = pAction;
					fBestValuate = fValue;
				}
				else
				{
					delete pBestAction;
				}

				break;
				*/
			}
		}
	}

	//return pBestAction;
	return NULL;
}
コード例 #2
0
IBActionDef* IBActionLibrary::FindActionDef(const string& factname)
{
	ActionDefMap::iterator begin = m_oMap.begin();
	ActionDefMap::iterator end = m_oMap.end();
	ActionDefMap::iterator it;

	for (it=begin ; it!=end ; ++it)
	{
		IBActionDef* pActionDef = it->second;

		for (uint i=0 ; i< pActionDef->GetPostCondDef().size() ; ++i)
		{
			IBFactDef* pFactDef = pActionDef->GetPostCondDef()[i].m_pFactDef;
			if (pFactDef->GetName() == factname)
			{
				return pActionDef;
			}
		}
	}

	return NULL;
}