本文整理汇总了C++中ActionNode::getPrerequisites方法的典型用法代码示例。如果您正苦于以下问题:C++ ActionNode::getPrerequisites方法的具体用法?C++ ActionNode::getPrerequisites怎么用?C++ ActionNode::getPrerequisites使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActionNode
的用法示例。
在下文中一共展示了ActionNode::getPrerequisites方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DoNextAction
bool Engine::DoNextAction(Unit* unit, int depth)
{
LogAction("--- AI Tick ---");
if (sPlayerbotAIConfig.logValuesPerTick)
LogValues();
bool actionExecuted = false;
ActionBasket* basket = NULL;
time_t currentTime = time(0);
aiObjectContext->Update();
ProcessTriggers();
int iterations = 0;
int iterationsPerTick = queue.Size() * sPlayerbotAIConfig.iterationsPerTick;
do {
basket = queue.Peek();
if (basket) {
if (++iterations > iterationsPerTick)
break;
float relevance = basket->getRelevance(); // just for reference
bool skipPrerequisites = basket->isSkipPrerequisites();
Event event = basket->getEvent();
// NOTE: queue.Pop() deletes basket
ActionNode* actionNode = queue.Pop();
Action* action = InitializeAction(actionNode);
if (!action)
{
LogAction("A:%s - UNKNOWN", actionNode->getName().c_str());
}
else if (action->isUseful())
{
for (list<Multiplier*>::iterator i = multipliers.begin(); i!= multipliers.end(); i++)
{
Multiplier* multiplier = *i;
relevance *= multiplier->GetValue(action);
if (!relevance)
{
LogAction("Multiplier %s made action %s useless", multiplier->getName().c_str(), action->getName().c_str());
break;
}
}
if (action->isPossible() && relevance)
{
if (!skipPrerequisites)
{
LogAction("A:%s - PREREQ", action->getName().c_str());
if (MultiplyAndPush(actionNode->getPrerequisites(), relevance + 0.02, false, event, "prereq"))
{
PushAgain(actionNode, relevance + 0.01, event);
continue;
}
}
actionExecuted = ListenAndExecute(action, event);
if (actionExecuted)
{
LogAction("A:%s - OK", action->getName().c_str());
MultiplyAndPush(actionNode->getContinuers(), 0, false, event, "cont");
lastRelevance = relevance;
delete actionNode;
break;
}
else
{
LogAction("A:%s - FAILED", action->getName().c_str());
MultiplyAndPush(actionNode->getAlternatives(), relevance + 0.03, false, event, "alt");
}
}
else
{
LogAction("A:%s - IMPOSSIBLE", action->getName().c_str());
MultiplyAndPush(actionNode->getAlternatives(), relevance + 0.03, false, event, "alt");
}
}
else
{
lastRelevance = relevance;
LogAction("A:%s - USELESS", action->getName().c_str());
}
delete actionNode;
}
}
while (basket);
if (!basket)
{
lastRelevance = 0.0f;
PushDefaultActions();
if (queue.Peek() && depth < 2)
return DoNextAction(unit, depth + 1);
}
if (time(0) - currentTime > 1) {
LogAction("too long execution");
}
//.........这里部分代码省略.........