Steamhammer/Source/StrategyManager.cpp
bool StrategyManager::handleExtremeEmergency(BuildOrderQueue & queue)
{
	const int minWorkers = 3;
	const BWAPI::UnitType workerType = _selfRace.getWorker();
	const int nWorkers = UnitUtil::GetAllUnitCount(workerType);

	// NOTE This doesn't check whether the map has resources remaining!
	//      If not, we should produce workers only if needed for another purpose.
	// NOTE If we don't have enough minerals to make a worker, then we don't
	//      have enough minerals to make anything (since we're not zerg and can't make scourge).
	//      So don't bother.
	if (nWorkers < minWorkers && BWAPI::Broodwar->self()->minerals() >= 50)
	{
		// 1. If the next item in the queue is a worker, we're good. Otherwise, clear the queue.
		// This is a severe emergency and it doesn't make sense to continue business as usual.
		// But if we don't have enough 
		if (queue.size() > 0)
		{
			const MacroAct & act = queue.getHighestPriorityItem().macroAct;
			if (act.isUnit() && act.getUnitType() == workerType)
			{
				return false;
			}
			queue.clearAll();
		}
		// 2. Queue the minimum number of workers.
		for (int i = nWorkers; i < minWorkers; ++i)
		{
			queue.queueAsHighestPriority(workerType);
		}
		return true;
	}

	return false;
}
// This tries to cope with 1 kind of severe emergency: We have desperately few workers.
// The caller promises that we have a resource depot, so we may be able to make more.
This tries to cope with 1 kind of severe emergency: We have desperately few workers.
The caller promises that we have a resource depot, so we may be able to make more.
This tries to cope with 1 kind of severe emergency : We have desperately few workers . The caller promises that we have a resource depot so we may be able to make more .
bool StrategyManager::handleExtremeEmergency(BuildOrderQueue & queue)
{
	const int minWorkers = 3;
	const BWAPI::UnitType workerType = _selfRace.getWorker();
	const int nWorkers = UnitUtil::GetAllUnitCount(workerType);
	if (nWorkers < minWorkers && BWAPI::Broodwar->self()->minerals() >= 50)
	{
		if (queue.size() > 0)
		{
			const MacroAct & act = queue.getHighestPriorityItem().macroAct;
			if (act.isUnit() && act.getUnitType() == workerType)
			{
				return false;
			}
			queue.clearAll();
		}
		for (int i = nWorkers; i < minWorkers; ++i)
		{
			queue.queueAsHighestPriority(workerType);
		}
		return true;
	}
	return false;
}
bool StrategyManager :: handleExtremeEmergency ( BuildOrderQueue & queue ) { const int minWorkers = 3 ; const BWAPI :: UnitType workerType = _selfRace . getWorker ( ) ; const int nWorkers = UnitUtil :: GetAllUnitCount ( workerType ) ; if ( nWorkers < minWorkers && BWAPI :: Broodwar -> self ( ) -> minerals ( ) >= 50 ) { if ( queue . size ( ) > 0 ) { const MacroAct & act = queue . getHighestPriorityItem ( ) . macroAct ; if ( act . isUnit ( ) && act . getUnitType ( ) == workerType ) { return false ; } queue . clearAll ( ) ; } for ( int i = nWorkers ; i < minWorkers ; ++ i ) { queue . queueAsHighestPriority ( workerType ) ; } return true ; } return false ; }
This tries to cope with 1 kind of severe emergency: We have desperately few workers.
This tries to cope with 1 kind of severe emergency : We have desperately few workers .
// NOTE This doesn't check whether the map has resources remaining! //      If not, we should produce workers only if needed for another purpose. // NOTE If we don't have enough minerals to make a worker, then we don't //      have enough minerals to make anything (since we're not zerg and can't make scourge). //      So don't bother. // 1. If the next item in the queue is a worker, we're good. Otherwise, clear the queue. // This is a severe emergency and it doesn't make sense to continue business as usual. // But if we don't have enough  // 2. Queue the minimum number of workers.