本文整理汇总了C++中ActionSet::popAction方法的典型用法代码示例。如果您正苦于以下问题:C++ ActionSet::popAction方法的具体用法?C++ ActionSet::popAction怎么用?C++ ActionSet::popAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActionSet
的用法示例。
在下文中一共展示了ActionSet::popAction方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: calculateDependencyGraph
void calculateDependencyGraph()
{
// zero out the graph
DG = DependencyGraph<bool>(size());
// for each action we have
for (size_t a=0; a<actions.size(); ++a)
{
// get the prerequisites for this action
ActionSet pre = actions[a].getPrerequisites();
// subtract the worker from resource depot, prevent cyclic dependency
if (a == DATA.getResourceDepot())
{
pre.subtract(DATA.getWorker());
}
// loop through prerequisites
while (!pre.isEmpty())
{
// get the next action
Action p = pre.popAction();
// add it to the dependency graph
DG.set(a, p, true);
}
}
// do transitive reduction to obtain the tree
DG.transitiveReduction();
}
示例2: printActionNames
void printActionNames(ActionSet s)
{
while (!s.isEmpty())
{
Action a = s.popAction();
printf("%s\n", getStarcraftAction(a).getName().c_str());
}
}
示例3: whenActionsFinished
FrameCountType whenActionsFinished(ActionSet actions) const
{
assert(!actions.isEmpty());
// the maximum of the (minimums for each action)
int totalMax = 0;
// if there are actions still left
while (!actions.isEmpty())
{
// pop an action off the set
Action a = actions.popAction();
// define a new minimum
int actionMin = INT_MAX;
// for each unit in our progress vector
for (int i(0); i<inProgressSize; ++i)
{
// if the action matches
if (inProgress[i].action == a)
{
// check to see if we have a new minimum
actionMin = (inProgress[i].time < actionMin) ? inProgress[i].time : actionMin;
}
}
// if we found a new minimum
if (actionMin < INT_MAX)
{
// check to see if we have a new maximum
totalMax = (actionMin > totalMax) ? actionMin : totalMax;
}
}
// return the new maximum
return totalMax;
}
示例4: DFBB
// recursive function which does all search logic
void DFBB(StarcraftStateType & s, int depth)
{
// increase the node expansion count
nodesExpanded++;
//graphVizOutput(s, false);
// the time at which the last thing in the queue will finish
int finishTime = s.getLastFinishTime();
if (finishTime >= upperBound)
{
return;
}
int lookupVal = TT.lookup(s.hashAllUnits(1), s.hashAllUnits(2));
if (lookupVal != -1 && lookupVal < finishTime)
{
ttcuts++;
return;
}
TT.save(s.hashAllUnits(1), s.hashAllUnits(2), finishTime);
int bucket = getBucket(finishTime);
int armyValue = s.getArmyValue();
if (armyValue > armyValues[bucket])
{
armyValues[bucket] = armyValue;
buildOrders[bucket] = getBuildOrder(s);
}
// if we are using search timeout and we are over the limit
if (params.searchTimeLimit && (nodesExpanded % 1000 == 0) && (searchTimer.getElapsedTimeInMilliSec() > params.searchTimeLimit))
{
// throw an exception to unroll the recursion
throw 1;
}
// get the legal action set
ActionSet legalActions = s.getLegalActionsMonteCarlo(params.goal);
// if we have children, update the counter
if (!legalActions.isEmpty())
{
numGenerations += 1;
numChildren += legalActions.numActions();
}
// while there are still legal actions to perform
while (!legalActions.isEmpty())
{
// get the next action
Action nextAction = legalActions.popAction();
bool stillLegal = true;
StarcraftStateType child(s);
// set the repetitions if we are using repetitions, otherwise set to 1
int repeat = params.useRepetitions ? params.getRepetitions(nextAction) : 1;
// for each repetition of this action
for (int r = 0; r < repeat; ++r)
{
// if the action is still legal
if (child.isLegalMonteCarlo(nextAction, params.goal))
{
int readyTime = child.resourcesReady(nextAction);
child.doAction(nextAction, readyTime);
}
// if it's not legal, break the chain
else
{
stillLegal = false;
break;
}
}
//if (stillLegal)
//{
child.setParent(&s);
child.setActionPerformedK((UnitCountType)repeat);
DFBB(child, depth+1);
//}
}
}
示例5: DFBB
//.........这里部分代码省略.........
// throw an exception to unroll the recursion
throw 1;
}
// get the legal action set
ActionSet legalActions = s.getLegalActions(params.goal);
// only use relevant actions
legalActions = legalActions & relevantActions;
// if we enabled the supply bounding flag
if (params.useSupplyBounding)
{
// if we are more than 2 supply providers in the lead
if ((s.getMaxSupply() - s.getCurrentSupply()) >= params.supplyBoundingThreshold*DATA[DATA.getSupplyProvider()].supplyProvided())
{
// make supply providers illegal
legalActions.subtract(DATA.getSupplyProvider());
}
}
// if we enabled the always make workers flag, and workers are legal
if (params.useAlwaysMakeWorkers && !params.goal[DATA.getWorker()] && legalActions[DATA.getWorker()])
{
ActionSet tempLegal(legalActions);
ActionSet legalBeforeWorker;
// compute when the next worker will be trainable
int workerReady = s.resourcesReady(DATA.getWorker());
// for each other legal action
while (!tempLegal.isEmpty())
{
Action nextAction = tempLegal.popAction();
// if the action will be ready before the next worker
if (s.resourcesReady(nextAction) <= workerReady)
{
// it's legal
legalBeforeWorker.add(nextAction);
}
}
// update the legal actions
legalActions = legalBeforeWorker;
}
// if we enabled the use worker cutoff flag and we're above the cutoff
if (params.useWorkerCutoff && s.getCurrentFrame() > (params.workerCutoff * upperBound))
{
// workers are no longer legal
legalActions.subtract(DATA.getWorker());
// if we have enough supply for the remaining goal
if (s.hasEnoughSupplyForGoal(params.goal))
{
// make supply providers illegal
legalActions.subtract(DATA.getSupplyProvider());
}
}
// if we have children, update the counter
if (!legalActions.isEmpty())
{
numGenerations += 1;
numChildren += legalActions.numActions();