本文整理汇总了C++中ActionSet::size方法的典型用法代码示例。如果您正苦于以下问题:C++ ActionSet::size方法的具体用法?C++ ActionSet::size怎么用?C++ ActionSet::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActionSet
的用法示例。
在下文中一共展示了ActionSet::size方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doSearch
void CombatSearch_BestResponse::doSearch(const GameState & state, size_t depth)
{
if (timeLimitReached())
{
throw BOSS_COMBATSEARCH_TIMEOUT;
}
_bestResponseData.update(_params.getInitialState(), state, _buildOrder);
updateResults(state);
if (isTerminalNode(state, depth))
{
return;
}
ActionSet legalActions;
generateLegalActions(state, legalActions, _params);
for (UnitCountType a(0); a < legalActions.size(); ++a)
{
size_t ri = legalActions.size() - 1 - a;
GameState child(state);
child.doAction(legalActions[ri]);
_buildOrder.add(legalActions[ri]);
doSearch(child,depth+1);
_buildOrder.pop_back();
}
}
示例2: generateLegalActions
void DFBB_BuildOrderStackSearch::generateLegalActions(const GameState & state, ActionSet & legalActions)
{
legalActions.clear();
DFBB_BuildOrderSearchGoal & goal = _params.goal;
const ActionType & worker = ActionTypes::GetWorker(state.getRace());
// add all legal relevant actions that are in the goal
for (size_t a(0); a < _params.relevantActions.size(); ++a)
{
const ActionType & actionType = _params.relevantActions[a];
if (state.isLegal(actionType))
{
// if there's none of this action in the goal it's not legal
if (!goal.getGoal(actionType) && !goal.getGoalMax(actionType))
{
continue;
}
// if we alread have more than the goal it's not legal
if (goal.getGoal(actionType) && (state.getUnitData().getNumTotal(actionType) >= goal.getGoal(actionType)))
{
continue;
}
// if we already have more than the goal max it's not legal
if (goal.getGoalMax(actionType) && (state.getUnitData().getNumTotal(actionType) >= goal.getGoalMax(actionType)))
{
continue;
}
legalActions.add(_params.relevantActions[a]);
}
}
// don't make anything until we have 8 workers
if (state.getUnitData().getNumTotal(worker) < 8)
{
legalActions.clear();
legalActions.add(worker);
return;
}
// if we enabled the supply bounding flag
if (_params.useSupplyBounding)
{
UnitCountType supplySurplus = state.getUnitData().getMaxSupply() + state.getUnitData().getSupplyInProgress() - state.getUnitData().getCurrentSupply();
UnitCountType threshold = (UnitCountType)(ActionTypes::GetSupplyProvider(state.getRace()).supplyProvided() * _params.supplyBoundingThreshold);
if (supplySurplus >= threshold)
{
legalActions.remove(ActionTypes::GetSupplyProvider(state.getRace()));
}
}
// if we enabled the always make workers flag, and workers are legal
if (_params.useAlwaysMakeWorkers && legalActions.contains(worker))
{
bool actionLegalBeforeWorker = false;
ActionSet legalEqualWorker;
FrameCountType workerReady = state.whenCanPerform(worker);
for (size_t a(0); a < legalActions.size(); ++a)
{
const ActionType & actionType = legalActions[a];
const FrameCountType whenCanPerformAction = state.whenCanPerform(actionType);
if (whenCanPerformAction < workerReady)
{
actionLegalBeforeWorker = true;
break;
}
if ((whenCanPerformAction == workerReady) && (actionType.mineralPrice() == worker.mineralPrice()))
{
legalEqualWorker.add(actionType);
}
}
if (actionLegalBeforeWorker)
{
legalActions.remove(worker);
}
else
{
legalActions = legalEqualWorker;
}
}
}