// 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))); } }
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(); } }
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); }
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); } }