Exemplo n.º 1
0
double GoalBombard::Compute_Matching_Value
(
	AiMain *ai,
	squad_ptr the_squad
)
{

	double utility;
	double summed_utility = 0.0;
	double avg_utility;
	int unit_count;
	ArmyAgent *tmpAgent;
	BOOL same_squad_goal_combo;




	unit_count = the_squad->GetUnitCount();

	if (unit_count <= 0)
		return BAD_UTILITY;

	sint32 found_agents = 0;
	for (int i = 0; i< unit_count; i++)
		{
			tmpAgent = (ArmyAgent *) the_squad->GetUnitByNumber(i);
			utility = Action_Bid(ai, tmpAgent);
			if (utility > BAD_UTILITY + 0.5)
			{
				summed_utility += utility;
				found_agents++;
			}

	}

	if (found_agents > 0)
	{

		avg_utility = summed_utility / found_agents;
	}
	else

		return BAD_UTILITY;

	same_squad_goal_combo = (the_squad->last_goal_type is what_goal);

	if (same_squad_goal_combo)
	{

		avg_utility += ai->m_planner->the_AIP.persistence_modifier;

	}

	return (avg_utility);
}
Exemplo n.º 2
0
double GoalSally::Compute_Matching_Value
(
	AiMain *ai,							
	squad_ptr the_squad				
)
{
	
	double utility;					
	double summed_utility = 0.0;	
	double avg_utility;				
	int unit_count;					
	ArmyAgent *tmpAgent;			
	

	
	unit_count = the_squad->GetUnitCount();

	
	if (unit_count <= 0) 
		return BAD_UTILITY;

	
	sint32 found_agents = 0;
	for (int i = 0; i< unit_count; i++)
		{
			tmpAgent = (ArmyAgent *) the_squad->GetUnitByNumber(i);
			utility = Action_Bid(ai, tmpAgent);
			if (utility > BAD_UTILITY + 0.5)
			{
				summed_utility += utility;
				found_agents++;
			}

	} 

	
	if (found_agents > 0)
	{
		
		avg_utility = summed_utility / found_agents;
	}
	else
		
		return BAD_UTILITY;

	
	return (avg_utility);
}