本文整理汇总了C++中ActionType::isSupplyProvider方法的典型用法代码示例。如果您正苦于以下问题:C++ ActionType::isSupplyProvider方法的具体用法?C++ ActionType::isSupplyProvider怎么用?C++ ActionType::isSupplyProvider使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActionType
的用法示例。
在下文中一共展示了ActionType::isSupplyProvider方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
}
示例2: recurseOverStrictDependencies
// recursively checks the tech tree of Action and sets each to have goalMax of 1
void DFBB_BuildOrderSmartSearch::recurseOverStrictDependencies(const ActionType & actionType)
{
if (actionType.isResourceDepot() || actionType.isWorker() || actionType.isSupplyProvider() || actionType.isRefinery())
{
return;
}
PrerequisiteSet recursivePrerequisites = actionType.getRecursivePrerequisites();
for (size_t a(0); a < recursivePrerequisites.size(); ++a)
{
const ActionType & actionType = recursivePrerequisites.getActionType(a);
if (actionType.isResourceDepot() ||actionType.isWorker() || actionType.isSupplyProvider() || actionType.isRefinery())
{
continue;
}
_goal.setGoalMax(actionType, std::max((UnitCountType)1, _goal.getGoalMax(actionType)));
}
}
示例3: removeCompletedAction
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();
}
}
示例4: addCompletedAction
void UnitData::addCompletedAction(const ActionType & action, bool wasBuilt)
{
const static ActionType Lair = ActionTypes::GetActionType("Zerg_Lair");
const static ActionType Hive = ActionTypes::GetActionType("Zerg_Hive");
_numUnits[action.ID()] += action.numProduced();
if (wasBuilt)
{
// a lair or hive from a hatchery don't produce additional supply
if (action != Lair && action != Hive)
{
_maxSupply += action.supplyProvided();
}
}
else
{
_maxSupply += action.supplyProvided();
}
if (action.isWorker())
{
_mineralWorkers++;
}
// 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())
{
if (!action.isMorphed())
{
_buildings.addBuilding(action, ActionTypes::None);
}
}
// special case for hatcheries
if (action.isBuilding() && (action.getUnitType() == BWAPI::UnitTypes::Zerg_Hatchery))
{
_hatcheryData.addHatchery(wasBuilt ? 1 : 3);
}
}
示例5: whyIsNotLegal
bool GameState::whyIsNotLegal(const ActionType & action) const
{
const size_t numRefineries = _units.getNumTotal(ActionTypes::GetRefinery(getRace()));
const size_t numDepots = _units.getNumTotal(ActionTypes::GetResourceDepot(getRace()));
const size_t refineriesInProgress = _units.getNumInProgress(ActionTypes::GetRefinery(getRace()));
// we can never build a larva
static const ActionType & Zerg_Larva = ActionTypes::GetActionType("Zerg_Larva");
if (action == Zerg_Larva)
{
std::cout << "WhyNotLegal: " << action.getName() << " - Cannot build a Larva" << std::endl;
return false;
}
// check if the tech requirements are met
if (!_units.hasPrerequisites(action.getPrerequisites()))
{
std::cout << "WhyNotLegal: " << action.getName() << " - Tech requirements not met" << std::endl;
return false;
}
// if it's a unit and we are out of supply and aren't making an overlord, it's not legal
if (!action.isMorphed() && ((_units.getCurrentSupply() + action.supplyRequired()) > (_units.getMaxSupply() + _units.getSupplyInProgress())))
{
std::cout << "WhyNotLegal: " << action.getName() << " - Not enough supply to construct" << std::endl;
return false;
}
// specific rule for never leaving 0 workers on minerals
if (action.isRefinery() && (getNumMineralWorkers() <= 4))
{
std::cout << "WhyNotLegal: " << action.getName() << " - Cannot leave 0 workers on minerals" << std::endl;
return false;
}
// if it's a new building and no drones are available, it's not legal
if (!action.isMorphed() && action.isBuilding() && (getNumMineralWorkers() <= 1) && (getNumBuildingWorkers() == 0))
{
std::cout << "WhyNotLegal: " << action.getName() << " - No building worker available" << std::endl;
return false;
}
// we can't build a building with our last worker
if (!action.isMorphed() && action.isBuilding() && (getNumMineralWorkers() <= 1 + 3*refineriesInProgress) && (getNumBuildingWorkers() == 0))
{
std::cout << "WhyNotLegal: " << action.getName() << " - Can't build with last worker" << std::endl;
return false;
}
// if we have no gas income we can't make a gas unit
if (!canAffordGas(action) && !_units.hasGasIncome())
{
std::cout << "WhyNotLegal: " << action.getName() << " - No gas income for gas unit" << std::endl;
return false;
}
// if we have no mineral income we'll never have a minerla unit
if (!canAffordMinerals(action) && !_units.hasMineralIncome())
{
std::cout << "WhyNotLegal: " << action.getName() << " - No mineral income" << std::endl;
return false;
}
// don't build more refineries than resource depots
if (action.isRefinery() && (numRefineries >= numDepots))
{
std::cout << "WhyNotLegal: " << action.getName() << " - Can't have more refineries than depots" << std::endl;
return false;
}
// we don't need to go over the maximum supply limit with supply providers
if (action.isSupplyProvider() && (_units.getMaxSupply() + _units.getSupplyInProgress() >= 400))
{
std::cout << "WhyNotLegal: " << action.getName() << " - Can't go over max supply bound with providers" << std::endl;
return false;
}
if (action.isTech() && getUnitData().getNumTotal(action) > 0)
{
std::cout << "WhyNotLegal: " << action.getName() << " - Can't produce additional copy of tech" << std::endl;
return false;
}
return true;
}
示例6: isLegal
bool GameState::isLegal(const ActionType & action) const
{
const size_t numRefineries = _units.getNumTotal(ActionTypes::GetRefinery(getRace()));
const size_t numDepots = _units.getNumTotal(ActionTypes::GetResourceDepot(getRace()));
const size_t refineriesInProgress = _units.getNumInProgress(ActionTypes::GetRefinery(getRace()));
// we can never build a larva
static const ActionType & Zerg_Larva = ActionTypes::GetActionType("Zerg_Larva");
if (action == Zerg_Larva)
{
return false;
}
// check if the tech requirements are met
if (!_units.hasPrerequisites(action.getPrerequisites()))
{
return false;
}
// if it's a unit and we are out of supply and aren't making an overlord, it's not legal
if (!action.isMorphed() && !action.isSupplyProvider() && ((_units.getCurrentSupply() + action.supplyRequired()) > (_units.getMaxSupply() + _units.getSupplyInProgress())))
{
return false;
}
// TODO: require an extra for refineries byt not buildings
// rules for buildings which are built by workers
if (action.isBuilding() && !action.isMorphed() && !action.isAddon())
{
// be very strict about when we can make refineries to ensure we have enough workers to go in gas
if (action.isRefinery() && (getNumMineralWorkers() <= (4 + 3*refineriesInProgress)))
{
return false;
}
int workersPerRefinery = 3;
int workersRequiredToBuild = getRace() == Races::Protoss ? 0 : 1;
int buildingIsRefinery = action.isRefinery() ? 1 : 0;
int candidateWorkers = getNumMineralWorkers() + _units.getNumInProgress(ActionTypes::GetWorker(getRace())) + getNumBuildingWorkers();
int workersToBeUsed = workersRequiredToBuild + workersPerRefinery*(refineriesInProgress);
if (candidateWorkers < workersToBeUsed)
{
return false;
}
}
// if we have no gas income we can't make a gas unit
if (!canAffordGas(action) && !_units.hasGasIncome())
{
return false;
}
// if we have no mineral income we'll never have a minerla unit
if (!canAffordMinerals(action) && !_units.hasMineralIncome())
{
return false;
}
// don't build more refineries than resource depots
if (action.isRefinery() && (numRefineries >= numDepots))
{
return false;
}
// we don't need to go over the maximum supply limit with supply providers
if (action.isSupplyProvider() && (_units.getMaxSupply() + _units.getSupplyInProgress() > 400))
{
return false;
}
// can only build one of a tech type
if (action.isTech() && getUnitData().getNumTotal(action) > 0)
{
return false;
}
// check to see if an addon can ever be built
if (action.isAddon() && !_units.getBuildingData().canBuildEventually(action) && (_units.getNumInProgress(action.whatBuildsActionType()) == 0))
{
return false;
}
return true;
}