Beispiel #1
0
void Action::applyAction(model::Move &move)
{
    if (left < 100)
        move.set_left_track_power(left);
    if (right < 100)
        move.set_right_track_power(right);
    if (turretRotate < 100)
        move.set_turret_turn(turretRotate);
    if (fireType != model::UNKNOWN_FIRE)
        move.set_fire_type(fireType);
}
Beispiel #2
0
void GoToUnit( Unit * pBonus, Tank & self, model::Move & move )
{
	double orig_angle = self.GetAngleTo(*pBonus);
	double angle = orig_angle;
	double fangle = fabs(orig_angle);
	double dist = self.GetDistanceTo( *pBonus );

	double MIN_ANGLE_B = dist*0.0005;

	double direction = 1.0;

	if (orig_angle > PI_D_2)
	{
		angle = M_PI - fangle;
		direction = -1.0;
	}

	if (orig_angle < -PI_D_2)
	{
		angle = fangle - M_PI;
		direction = -1.0;
	}

	if (fangle > PI_D_2)
	{
		if ( angle > MIN_ANGLE_B )
		{
			move.set_left_track_power(-self.engine_power());
			move.set_right_track_power( self.engine_power() - self.engine_rear_power_factor() ); //(.75);
		}
		else if ( angle < -MIN_ANGLE_B )
		{
			move.set_left_track_power(self.engine_power() - self.engine_rear_power_factor() );//(.75);
			move.set_right_track_power(-self.engine_power());	
		}
		else
		{
			move.set_left_track_power(direction*1);
			move.set_right_track_power(direction*1);
		}
	}
	else
	{
		if ( angle > MIN_ANGLE_B )
		{
			move.set_left_track_power(self.engine_power() - self.engine_rear_power_factor() );//(.75);
			move.set_right_track_power(-self.engine_power());	
		}
		else if ( angle < -MIN_ANGLE_B )
		{
			move.set_left_track_power(-self.engine_power());
			move.set_right_track_power( self.engine_power() - self.engine_rear_power_factor() ); //(.75);
		}
		else
		{
			move.set_left_track_power(direction*1);
			move.set_right_track_power(direction*1);
		}
	}
}
Beispiel #3
0
void MyStrategy::Move(Tank self, World world, model::Move& move)
{
	if (world.tick() == 1)
	{
		FirstTick(self, world);
	}

	vector<Tank> t = world.tanks();
	vector<Shell> s = world.shells();
	vector<Bonus> b = world.bonuses();

	double xForce = 0 , yForce = 0 ;

	for (int i = 0; i < t.size(); ++i)
	{
		if (self.id() == t[i].id())
			continue;

		if (EnemyDead(&t[i]))
			continue;

		ForceModify( self, t[i], xForce, yForce, -1.0 );
	}

	Bonus * pBonus = 0;

	if ( !TimeToHide( self, world, move ) )
	{
	
		pBonus = get_need_id(g_need_id, b);

		//pBonus = GetNeededBonus( self, b );

		if (!pBonus || ( pBonus->type() != MEDIKIT && HealthIsCritical(self) ) )
		{
			pBonus = GetNeededBonus( self, b );
		}

	}

	for (int i = 0; i < b.size(); ++i)
	{

		double bonusPower = 1.0;

		if (pBonus && b[i].id() == pBonus->id())
		{
			bonusPower = 10000.0;
		}

		ForceModify( self, b[i], xForce, yForce, bonusPower );
	}

	/* for (int i = 0; i < s.size(); ++i)
	{
		if (self.player_name() != s[i].player_name())
		{
			ForceModify( self, s[i], xForce, yForce, -100000.0 );
		}
	} */

	double orig_angle = atan2(xForce, yForce);

	double angle = orig_angle;

	double fangle = fabs(angle);

	double MIN_ANGLE_B = M_PI/30.0;

	double dir = 1.0;
	double s_angle = self.angle();

	if (orig_angle > PI_D_2)
	{
		angle = M_PI - fangle;
		dir = -1.0;
	}

	if (orig_angle < -PI_D_2)
	{
		angle = fangle - M_PI;
		dir = -1.0;
	}

	if (fangle > PI_D_2)
	{
		if ( angle > MIN_ANGLE_B )
		{
			move.set_left_track_power(-1.0);
			move.set_right_track_power( .75 ); //(.75);
		}
		else if ( angle < -MIN_ANGLE_B )
		{
			move.set_left_track_power(.75 );//(.75);
			move.set_right_track_power(-1.0);	
		}
		else
		{
			move.set_left_track_power(dir*1);
			move.set_right_track_power(dir*1);
		}
	}
	else
	{
		if ( angle > MIN_ANGLE_B )
		{
			move.set_left_track_power(.75 );//(.75);
			move.set_right_track_power(-1.0);	
		}
		else if ( angle < -MIN_ANGLE_B )
		{
			move.set_left_track_power(-1.0);
			move.set_right_track_power( .75 ); //(.75);
		}
		else
		{
			move.set_left_track_power(dir*1);
			move.set_right_track_power(dir*1);
		}
	}

	//move.set_left_track_power(0);
	//move.set_right_track_power(0);

	Shoot( self, world, move );
}