コード例 #1
0
ファイル: GoalSally.cpp プロジェクト: talentlesshack/C2P2
double GoalSally::Action_Bid(AiMain *ai, Agent *agent)
{
	ArmyAgent *army_agent = (ArmyAgent *)agent;
	CityAgent *city_agent = (CityAgent *)agent;

	
	if (agent->GetType() == AGENT_TYPE_CITY)
		
		return city_agent->FindBestBuildUtility(ai,this,army_agent);

   	

	
	if (!PretestBid(ai, army_agent))
		return BAD_UTILITY;

	
	if (army_agent->GetState() == AGENT_STATE_UNBUILT) 
	{ 
        if (army_agent->GetHomeCityAgent()->GetQueueLen() > 0)  
            return BAD_UTILITY; 
    }

	double move_point_cost;
    sint32 rounds; 
    double build_time;
    if (army_agent->BidDistance(ai, FALSE, *m_pos, move_point_cost, rounds, build_time) < 0.0) { 
        return BAD_UTILITY; 
    }

	
	double bonuses = 0.0;
	sint32 best_attack;
	sint32 my_attack  = army_agent->GetBestAttack(ai);
	if (ai->m_science_agent->GetBestLandAttack(best_attack))
		bonuses += (1.0 - (my_attack / best_attack))
			* ai->m_planner->the_AIP.max_misc_bid_bonus;
	else
		; 

	
	double time_term;
    MapPointData dest_pos; 
    army_agent->GetPos(ai, dest_pos); 
	double tile_count = ai->m_map->WrappedDistance(*m_pos, dest_pos);
	time_term = ( rounds * rounds 
		* ai->m_planner->the_AIP.distance_from_unit_priority_modifier )
		- tile_count;

	return bonuses + time_term + Compute_Raw_Priority(ai); 
}
コード例 #2
0
double GoalMapTarget::Action_Bid(AiMain *ai, Agent *agent)
{
	ArmyAgent *army_agent = (ArmyAgent *)agent;
	CityAgent *city_agent = (CityAgent *)agent;
	BOOL ASSERT_MAP_TARGET_INVALID = 0;

	if (agent->GetType() == AGENT_TYPE_CITY)

		return city_agent->FindBestBuildUtility(ai,this,army_agent);




    if (army_agent->IsWounded()) return BAD_UTILITY;

	if (!PretestBid(ai, army_agent))
		return BAD_UTILITY;

	if (GetType() == GOAL_TYPE_TRANSPORT)
		return Compute_Raw_Priority(ai);

	if (army_agent->GetState() == AGENT_STATE_UNBUILT)
	{
        if (army_agent->GetHomeCityAgent()->GetQueueLen() > 0)
            return BAD_UTILITY;
    }

	double move_point_cost;
    sint32 rounds;
    double build_time;
    if (army_agent->BidDistance(ai, FALSE, *m_pos, move_point_cost, rounds, build_time) < 0.0) {
        return BAD_UTILITY;
    }

	if (ai->my_player_index == PLAYER_INDEX_VANDALS &&
		rounds > ai->m_planner->the_AIP.wander_rounds_from_target &&
		GetType() != GOAL_TYPE_WANDER)
		return BAD_UTILITY;

	double high_movement_weight;
	double low_defense_weight;
	double high_defense_weight;
	double high_attack_weight;
	double bonus = 0.0;

	switch (GetType())
	{
		case GOAL_TYPE_PILLAGE:
		case GOAL_TYPE_PIRATE:
		case GOAL_TYPE_PROBE_WORMHOLE:

			high_movement_weight = 0.75;
			low_defense_weight = 0.25;
			high_defense_weight = 0.0;
			high_attack_weight = 0.0;
			break;
		case GOAL_TYPE_WANDER:

		case GOAL_TYPE_COUNTER_STEALTH:
		case GOAL_TYPE_BONUS_FOOD:
		case GOAL_TYPE_GOODY_HUT:

			high_movement_weight = 1.0;
			low_defense_weight = 0.0;
			high_defense_weight = 0.0;
			high_attack_weight = 0.0;
			break;
		case GOAL_TYPE_CHOKEPOINT:

			high_movement_weight = 0.0;
			low_defense_weight = 0.0;
			high_defense_weight = 0.75;
			high_attack_weight = 0.25;
			break;
		default:
			Assert(ASSERT_MAP_TARGET_INVALID);
	}

	sint32 best_defense;
	sint32 my_defense  = army_agent->GetBestDefense(ai);
	if (ai->m_science_agent->GetBestLandDefense(best_defense))
		{
			bonus += (1.0 - (my_defense / best_defense))
				* ai->m_planner->the_AIP.max_misc_bid_bonus
				* low_defense_weight;
		}
	else
		;

	sint32 best_move;
	double my_move = army_agent->GetBestMove(ai);
	if (ai->m_science_agent->GetBestLandMove(best_move))
		bonus += (my_move / best_move)
			* ai->m_planner->the_AIP.max_misc_bid_bonus
			* high_movement_weight;
	else
		;

	if (ai->m_science_agent->GetBestLandDefense(best_defense))
		{
			bonus += (my_defense / best_defense)
				* ai->m_planner->the_AIP.max_misc_bid_bonus
				* high_defense_weight;
		}
	else
		;

	sint32 best_attack;
	sint32 my_attack  = army_agent->GetBestAttack(ai);
	if (ai->m_science_agent->GetBestLandAttack(best_attack))
		{
			if(best_attack == 0) {

				best_attack = 1;
			}
			bonus += (my_attack / best_attack)
				* ai->m_planner->the_AIP.max_misc_bid_bonus
				* high_attack_weight;
		}
	else
		;

	double time_term;
    MapPointData dest_pos;
    army_agent->GetPos(ai, dest_pos);
	double tile_count = ai->m_map->WrappedDistance(*m_pos, dest_pos);
	time_term = ( rounds * rounds
		* ai->m_planner->the_AIP.distance_from_unit_priority_modifier )
		- tile_count;

	return bonus + time_term + Compute_Raw_Priority(ai);
}
コード例 #3
0
double GoalBombard::Action_Bid(AiMain *ai, Agent *agent)
{
	ArmyAgent *army_agent = (ArmyAgent *)agent;
	CityAgent *city_agent = (CityAgent *)agent;

	if (agent->GetType() == AGENT_TYPE_CITY)

		return city_agent->FindBestBuildUtility(ai,this,army_agent);






	if (!PretestBid(ai, army_agent))
		return BAD_UTILITY;

	if (army_agent->GetState() == AGENT_STATE_UNBUILT)
	{
        if (army_agent->GetHomeCityAgent()->GetQueueLen() > 0)
            return BAD_UTILITY;
    }

	double move_point_cost;
    sint32 rounds;


    MapPointData army_pos;
    army_agent->GetPos(ai, army_pos);
    MapPointData ignore_space = *m_pos;
    ignore_space.z = army_pos.z;

    double build_time;
    if (army_agent->BidDistance(ai, FALSE, ignore_space, move_point_cost, rounds, build_time) < 0.0) {
        return BAD_UTILITY;
    }

	if (ai->m_my_player_id == PLAYER_INDEX_VANDALS &&
		rounds > ai->m_planner->the_AIP.wander_rounds_from_target)
		return BAD_UTILITY;

	double high_movement_weight = 0.5;
	double high_attack_weight = 0.5;
	double bonuses = 0.0;

	sint32 best_attack;
	sint32 my_attack  = army_agent->GetBestAttack(ai);
	if (ai->m_science_agent->GetBestLandAttack(best_attack))
		{
			bonuses += (my_attack / best_attack)
				* ai->m_planner->the_AIP.max_misc_bid_bonus
				* high_attack_weight;
		}
	else
		;

	sint32 best_move;
	double my_move = army_agent->GetBestMove(ai);
	if (ai->m_science_agent->GetBestLandMove(best_move))
		bonuses += (my_move / best_move)
			* ai->m_planner->the_AIP.max_misc_bid_bonus
			* high_movement_weight;
	else
		;

	double time_term;
    MapPointData dest_pos;
    army_agent->GetPos(ai, dest_pos);
	double tile_count = ai->m_map->WrappedDistance(*m_pos, dest_pos);
	time_term = ( rounds * rounds
		* ai->m_planner->the_AIP.distance_from_unit_priority_modifier )
		- tile_count;

	return bonuses + time_term + Compute_Raw_Priority(ai);
}