Steamhammer/Source/StrategyManager.cpp
double StrategyManager::getProductionSaturation(BWAPI::UnitType producer) const
{
    // Look up overall count and idle count
    int numFacilities = 0;
    int idleFacilities = 0;
    for (const auto unit : BWAPI::Broodwar->self()->getUnits())
        if (unit->getType() == producer
            && unit->isCompleted()
            && unit->isPowered())
        {
            numFacilities++;
            if (unit->getRemainingTrainTime() < 12) idleFacilities++;
        }

    if (numFacilities == 0) return 0.0;

    return (double)(numFacilities - idleFacilities) / (double)numFacilities;
}
// Returns the percentage of our completed production facilities that are currently training something
Returns the percentage of our completed production facilities that are currently training something
Returns the percentage of our completed production facilities that are currently training something
double StrategyManager::getProductionSaturation(BWAPI::UnitType producer) const
{
    int numFacilities = 0;
    int idleFacilities = 0;
    for (const auto unit : BWAPI::Broodwar->self()->getUnits())
        if (unit->getType() == producer
            && unit->isCompleted()
            && unit->isPowered())
        {
            numFacilities++;
            if (unit->getRemainingTrainTime() < 12) idleFacilities++;
        }
    if (numFacilities == 0) return 0.0;
    return (double)(numFacilities - idleFacilities) / (double)numFacilities;
}
double StrategyManager :: getProductionSaturation ( BWAPI :: UnitType producer ) const { int numFacilities = 0 ; int idleFacilities = 0 ; for ( const auto unit : BWAPI :: Broodwar -> self ( ) -> getUnits ( ) ) if ( unit -> getType ( ) == producer && unit -> isCompleted ( ) && unit -> isPowered ( ) ) { numFacilities ++ ; if ( unit -> getRemainingTrainTime ( ) < 12 ) idleFacilities ++ ; } if ( numFacilities == 0 ) return 0.0 ; return ( double ) ( numFacilities - idleFacilities ) / ( double ) numFacilities ; }
Returns the percentage of our completed production facilities that are currently training something
Returns the percentage of our completed production facilities that are currently training something
// Look up overall count and idle count