本文整理汇总了C++中ActionType类的典型用法代码示例。如果您正苦于以下问题:C++ ActionType类的具体用法?C++ ActionType怎么用?C++ ActionType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ActionType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setRepetitionThreshold
void DFBB_BuildOrderSearchParameters::setRepetitionThreshold(const ActionType & a, const UnitCountType & thresh)
{
BOSS_ASSERT(a.ID() >= 0 && a.ID() < repetitionThresholds.size(), "Action type not valid");
BOSS_ASSERT(a.getRace() == race, "Action type race doesn't match this parameter object");
repetitionThresholds[a.ID()] = thresh;
}
示例2: canBuildNow
const bool BuildingStatus::canBuildNow(const ActionType & action) const
{
if (_timeRemaining > 0)
{
return false;
}
if (!_type.canBuild(action))
{
return false;
}
if (action.isAddon() && (_addon != ActionTypes::None))
{
return false;
}
if (action.requiresAddon() && (_addon != action.requiredAddonType()))
{
return false;
}
return true;
}
示例3: addCompletedAction
ActionType UnitData::finishNextActionInProgress()
{
// get the actionUnit from the progress data
ActionType action = _progress.nextAction();
// add the unit to the unit counter
addCompletedAction(action);
// pop it from the progress vector
_progress.popNextAction();
if (getRace() == Races::Terran)
{
// if it's a building, release the worker back
if (action.isBuilding() && !action.isAddon())
{
releaseBuildingWorker();
}
}
else if (getRace() == Races::Zerg)
{
const static ActionType hatchery = ActionTypes::GetActionType("Zerg_Hatchery");
}
return action;
}
示例4: runActionState
void runActionState(ActionType& action) {
action.setState(ActionType::State::WALK);
runAllAction(action);
action.setState(ActionType::State::RUN);
runAllAction(action);
action.setState(ActionType::State::SLEEP);
runAllAction(action);
}
示例5: if
void UnitData::removeCompletedAction(const ActionType & action)
{
//Logger::LogAppendToFile(BOSS_LOGFILE, "Unit removed " + action.getName());
const static ActionType Lair = ActionTypes::GetActionType("Zerg_Lair");
const static ActionType Hive = ActionTypes::GetActionType("Zerg_Hive");
_numUnits[action.ID()] -= action.numProduced();
// a lair or hive from a hatchery don't produce additional supply
if (action != Lair && action != Hive)
{
_maxSupply -= action.supplyProvided();
}
if (action.isWorker())
{
if (_mineralWorkers > 0)
{
_mineralWorkers--;
}
else if (_gasWorkers > 0)
{
_gasWorkers--;
}
}
// if it's an extractor
if (action.isRefinery())
{
// take those workers from minerals and put them into it
_mineralWorkers += 3; _gasWorkers -= 3;
}
BOSS_ASSERT(_mineralWorkers >= 0, "Can't have negative mineral workers");
BOSS_ASSERT(_gasWorkers >= 0, "Can't have negative gas workers");
// if it's a building that can produce units, add it to the building data
if (action.isBuilding() && !action.isSupplyProvider())
{
if (!action.isMorphed())
{
_buildings.removeBuilding(action, ActionTypes::None);
}
}
// special case for hatcheries
if (action.isBuilding() && (action.getUnitType() == BWAPI::UnitTypes::Zerg_Hatchery))
{
_hatcheryData.removeHatchery();
}
}
示例6: addCompletedBuilding
// only used for adding existing buildings from a BWAPI Game * object
void UnitData::addCompletedBuilding(const ActionType & action, const FrameCountType timeUntilFree, const ActionType & constructing, const ActionType & addon)
{
_numUnits[action.ID()] += action.numProduced();
_maxSupply += action.supplyProvided();
// if it's an extractor
if (action.isRefinery())
{
// take those workers from minerals and put them into it
_mineralWorkers -= 3; _gasWorkers += 3;
}
// if it's a building that can produce units, add it to the building data
if (action.isBuilding() && !action.isSupplyProvider())
{
_buildings.addBuilding(action, timeUntilFree, constructing, addon);
}
// special case for hatcheries
if (action.isBuilding() && (action.getUnitType() == BWAPI::UnitTypes::Zerg_Hatchery))
{
_hatcheryData.addHatchery(1);
}
}
示例7: morphUnit
void UnitData::morphUnit(const ActionType & from, const ActionType & to, const FrameCountType & completionFrame)
{
BOSS_ASSERT(getNumCompleted(from) > 0, "Must have the unit type to morph it");
_numUnits[from.ID()]--;
_currentSupply -= from.supplyRequired();
if (from.isWorker())
{
BOSS_ASSERT(_mineralWorkers > 0, "Need mineral worker");
_mineralWorkers--;
}
addActionInProgress(to, completionFrame);
}
示例8: getPrerequistesInProgress
const PrerequisiteSet UnitData::getPrerequistesInProgress(const ActionType & action) const
{
PrerequisiteSet inProgress;
for (size_t a(0); a<action.getPrerequisites().size(); ++a)
{
const ActionType & actionType = action.getPrerequisites().getActionType(a);
if (getNumInProgress(actionType) > 0 && getNumCompleted(actionType) == 0)
{
inProgress.add(actionType);
}
}
return inProgress;
}
示例9: whenSupplyReady
const FrameCountType GameState::whenSupplyReady(const ActionType & action) const
{
int supplyNeeded = action.supplyRequired() + _units.getCurrentSupply() - _units.getMaxSupply();
if (supplyNeeded <= 0)
{
return getCurrentFrame();
}
FrameCountType whenSupplyReady = _currentFrame;
if (supplyNeeded > 0)
{
FrameCountType min = 99999;
// if we don't have the resources, this action would only be legal if there is an
// overlord in progress, so check to see when the first overlord will finish
for (int i(0); i<_units.getNumActionsInProgress(); ++i)
{
// so, if the unit provides the supply we need
if (_units.getActionInProgressByIndex(i).supplyProvided() > supplyNeeded)
{
// set 'min' to the min of these times
min = (_units.getFinishTimeByIndex(i) < min) ? _units.getFinishTimeByIndex(i) : min;
}
// then set supply time to min
whenSupplyReady = min;
}
}
return whenSupplyReady;
}
示例10: whenPrerequisitesReady
const FrameCountType GameState::whenPrerequisitesReady(const ActionType & action) const
{
if (action == ActionTypes::GetActionType("Protoss_Dark_Templar"))
{
int a = 6;
}
FrameCountType preReqReadyTime = _currentFrame;
// if a building builds this action
if (action.whatBuildsIsBuilding())
{
// get when the building / prereqs will be ready
preReqReadyTime = whenBuildingPrereqReady(action);
}
// otherwise something else builds this action so we don't worry about buildings
else
{
// if requirement in progress (and not already made), set when it will be finished
PrerequisiteSet reqInProgress = _units.getPrerequistesInProgress(action);
// if it's not empty, check when they will be done
if (!reqInProgress.isEmpty())
{
preReqReadyTime = _units.getFinishTime(reqInProgress);
}
}
return preReqReadyTime;
}
示例11: addAction
void ActionSet::addAction(const ActionType& action) {
if (action == ActionType::anyAction) {
addAllActions();
return;
}
_actions.set(action.getIdentifier(), true);
}
示例12: removeCompletedAction
void GameState::removeCompletedAction(const ActionType & action, const size_t num)
{
for (size_t i(0); i < num; ++i)
{
_units.setCurrentSupply(_units.getCurrentSupply() - action.supplyRequired());
_units.removeCompletedAction(action);
}
}
示例13: buildingAvailableTime
const FrameCountType GameState::whenBuildingPrereqReady(const ActionType & action) const
{
FrameCountType buildingAvailableTime(0);
const ActionType & builder = action.whatBuildsActionType();
BOSS_ASSERT(builder.isBuilding(), "The thing that builds this is not a building");
bool buildingIsConstructed = _units.getBuildingData().canBuildEventually(action);//getNumCompleted(builder) > 0;
bool buildingInProgress = _units.getNumInProgress(builder) > 0;
FrameCountType constructedBuildingFreeTime = std::numeric_limits<int>::max()-10;
FrameCountType buildingInProgressFinishTime = std::numeric_limits<int>::max()-10;
BOSS_ASSERT(buildingIsConstructed || (!action.requiresAddon() && buildingInProgress), "We will never be able to build action: %s", action.getName().c_str());
if (buildingIsConstructed)
{
constructedBuildingFreeTime = _currentFrame + _units.getBuildingData().getTimeUntilCanBuild(action);
}
if (!action.requiresAddon() && buildingInProgress)
{
buildingInProgressFinishTime = _units.getFinishTime(builder);
}
// this will give us when the building will be free to build this action
buildingAvailableTime = std::min(constructedBuildingFreeTime, buildingInProgressFinishTime);
// get all prerequisites currently in progress but do not have any completed
PrerequisiteSet prereqInProgress = _units.getPrerequistesInProgress(action);
// remove the specific builder from this list since we calculated that earlier
prereqInProgress.remove(builder);
//// if we actually have some prerequisites in progress other than the building
if (!prereqInProgress.isEmpty())
{
// get the max time the earliest of each type will be finished in
FrameCountType C = _units.getFinishTime(prereqInProgress);
// take the maximum of this value and when the building was available
buildingAvailableTime = (C > buildingAvailableTime) ? C : buildingAvailableTime;
}
return buildingAvailableTime;
}
示例14: canBuildEventually
const bool BuildingStatus::canBuildEventually(const ActionType & action) const
{
if (!_type.canBuild(action))
{
return false;
}
// if the type is an addon
if (action.isAddon())
{
// if we already have an addon we can't build it
if (_addon != ActionTypes::None)
{
return false;
}
// if we are building an addon we can't ever build it
if (_timeRemaining > 0 && _isConstructing.isAddon())
{
return false;
}
}
if (action.requiresAddon() && (_addon != action.requiredAddonType()))
{
if (_isConstructing != action.requiredAddonType())
{
return false;
}
}
// if the built type is morphed and we are morphing something, we won't be able to build it
if (action.isMorphed() && (_timeRemaining > 0) && (_isConstructing.isMorphed()))
{
return false;
}
return true;
}
示例15: removeBuilding
void BuildingData::removeBuilding(const ActionType & action, const ActionType & addon)
{
BOSS_ASSERT(action.isBuilding(), "Trying to remove a non-building from the building data");
for (size_t i = 0; i < _buildings.size(); i++)
{
if (_buildings[i]._type == action)
{
_buildings.remove(i);
break;
}
}
}