Foreword
This part describes how to Robocode enemy and constantly adjust itself to scan radar moves aim to achieve for a long time, and if the effect is achieved, it will not be our subsequent battle tanks it is important to increase the Fa code it!
Strategies aimed straight
Official figure
∠AEF = ∠α = the angle between the enemy and the Y-axis absolute angular (see previous example)
Bullets from E to F is the running time diff
Tank speed speed = ScannedRobotEvent getVelocity ().;
AB=speed*diff
We can calculate the coordinates of point B, A coordinate point (x, y)
newX = x + AB * Math.sina (a)
newY = y + EF * Math.cos (α)
Shells should be rotated angle normalRelativeAngle (α- getGunHeadingRadians ())
Circumference targeting strategy
The basic principle is:
change in x = cos(initialheading) * radius - cos(initialheading + changeinheading) * radius
change in y = sin(initialheading + changeinheading) * radius - sin(initialheading) * radius
Which is initialheading enemy robots in the direction of the initial position, change the direction of the bullet during flight is changeinheading, we assume that it is the radius of the circle with radius movement.
Official figure
Change direction every turn:
headingchangeperturn =
(Heading2 - heading1) / time value obtained, which is the time interval between two measurements;
Bullet exercise time:
time = getTime () + (range / (20- (3 * firepower))), where the range is the distance between us and the enemy launch, and we plan to use firepower is shooting fire;
半径:radius = velocity/headingchangeperturn
By setting the above formula can fully mobilize the radar and the angle of the barrel, more clearly their own tactics, do to cope, we all try it based on the understanding.
Well, this issue on here myself, I will not play games but have to write games Chen, together to learn JAVA now!