本文整理汇总了C++中ActionSet::subtract方法的典型用法代码示例。如果您正苦于以下问题:C++ ActionSet::subtract方法的具体用法?C++ ActionSet::subtract怎么用?C++ ActionSet::subtract使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActionSet
的用法示例。
在下文中一共展示了ActionSet::subtract方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: DFBB
// recursive function which does all search logic
void DFBB(StarcraftState & s, int depth)
{
// increase the node expansion count
nodesExpanded++;
// if we have constraints and they are not met
if (params.useConstraints && !s.meetsConstraints(params.ssc))
{
// this state is not legal
return;
}
// the time at which the last thing in the queue will finish
int finishTime = s.getLastFinishTime();
/*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);*/
// if we already have completed the units for the goal, don't worry about last finish time
if (s.meetsGoalCompleted(params.goal))
{
finishTime = s.getCurrentFrame();
}
// if we have met the goal, we're good
if (s.meetsGoal(params.goal))
{
// if it's better than the current best solution, set the new best
if (finishTime < upperBound)// || ((finishTime == upperBound) && (s.getWorkerCount() > winnerWorkerCount)))
{
// set the winning info
upperBound = finishTime;
winner = s;
winnerFound = true;
winnerWorkerCount = s.getWorkerCount();
results = SearchResults(true, upperBound, nodesExpanded, searchTimer.getElapsedTimeInMilliSec(), s.getBuildOrder());
results.upperBound = s.calculateUpperBoundHeuristic(params.goal);
results.lowerBound = s.eval(params.goal);
results.avgBranch = numChildren / (double)numGenerations;
results.minerals = s.getFinishTimeMinerals();
results.gas = s.getFinishTimeGas();
results.saveState = SearchSaveState(getBuildOrder(s), upperBound);
//graphVizOutput(s, true);
results.printResults(true);
s.printData();
return;
}
}
// if we are using search timeout and we are over the limit
// (nodesExpanded % 1000 == 0) only checks the time every 1000 expansions, since it is slow
if (params.searchTimeLimit && (nodesExpanded % 200 == 0) && (searchTimer.getElapsedTimeInMilliSec() > params.searchTimeLimit))
{
results.saveState = SearchSaveState(getBuildOrder(s), upperBound);
//results.saveState.print();
// 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())
//.........这里部分代码省略.........