Dynamic parameters Battle City Tank game series 5- to find the fun of learning JAVA

Dynamic parameters Battle City Tank game series 5- to find the fun of learning JAVA

Foreword

Benpian contains Robocode in more complex dynamic parameters, can fully understand the changes in the operation of the tank, an important indicator of familiar tanks lay a solid theoretical foundation for write good tanks.

Life parameters

Number of lives throughout the fight the most important point, we are all for it exists, when life is not the point, but also represents we lost the battle. We can () to get our robot hit points with function getEnergy.

1. Loss: collision losses: our tanks hit the wall, or collided with other tanks, will lose some of the value of life; the loss of hit: we were hit by bullets, of course, will be the loss of value of life; emission losses: We fired bullets will lose health.

2. Get: Gets the value of life only through the use of bullets hit the other tank.

Bullet parameters

Because a significant impact on the vitality of bullets, each of our bullets to use to harm, accurate calculation of the bullet and its energy value becomes very important.

* Bullet Energy:

By a bullet energy function getPower () obtained. It is greater than or equal to 0.1, 3 or less. * Bullet Speed:

Each bullet has its own speed, which you mobile strategy before the fire, but helpful in dealing with the enemy. And the bullet speed about its energy: speed = 20 - 3 * power.

Since the energy range between 0.1 to 3 we obtain bullet speed range: 11 <= bullet speed <= 19.7.

Parameters barrel

Bullet fired from the barrel, the barrel direction determines the direction of the bullet, the barrel also determines the heat emission bullets. Barrel will heat? Many people will be very surprised, yes. Real war is not the same in our guns will heat it? Robocode is not a real battlefield, the war can use the knowledge can be applied in the Robocode. The above parameters from the direction of our war static parameter description can be seen. Let us look at other parameters of the barrel:

* Rotation rate: rate of rotation of the barrel in each period = 20 degrees / frame (Frame)

* Barrel heat: when we opened fire, the energy that is decided when the barrel of the heat generated by the fire bullets: calories = 1 (firepower / 5), we can use the function getGunHeat () to get the heat gun barrel at the time, only when getGunHeat identically equal to zero, we can launch a bullet again. Now you understand why sometimes zero point in our lives for a reason and that bullets can not be fired yet? Barrel overheating! * Cooling degree: Of course there have cooling degree heat, no cooling of the barrel we will never be fired. The default setting of the cooling rate fighting system is 0.1 / tick (time period), we () function to get the parameter values ​​getGunCoolingRate. We can also set the cooling rate through the system. Select Battle-> New -> Rules-> Gun Cooling Rate.

Radar parameters

Radar is our eyes in the war, it can see and tell us the enemy's every move, Zhiyizhibi can not battle-Yi! * Speed ​​of rotation: the rotation speed of the radar 45 degrees per time period. I.e. 45 degrees / frame * Scan Area:

Scanning radar is fan-shaped, its length start position to the end position is about 1200. As long as we can estimate this to enlarge the screen area through the eyes. * Scan order: scanned data walled, goals and so on. These are arranged in the scanning distance, from the closest object to the last radar to scan the object.

Tanks parameters

Okay, back to our tank itself up. Let's look at some of what it parameters. * Forward speed: the maximum speed of our robots (Velocity) 8, function getVelocity () returns the current speed of our robots.

* Acceleration / deceleration Before we take a look at physics acceleration / deceleration method for finding, and some formulas related knowledge. We set S is a distance, Vt is the terminal velocity, Vo is the initial velocity, t is time, a is acceleration obtained as follows: displacement equation S = Vot + at2 / 2 speed formula Vt = Vo + at speed - displacement formulation Vt2-Vo2 = 2a average speed formula V = (Vt + Vo) / 2 = s / t acceleration equation a = (Vt-Vo) / t

We look at the acceleration / deceleration of Robocode: acceleration pixel (Pixel) / frame frame, deceleration 2 pixel / frame. If we robots from standstill to maximum speed, can be determined by the formula Time required (getTime) = 8/1 i.e. for a time period of 8, very interesting calculations, we also calculated accordingly more relevant and useful The data. * Speed ​​of rotation: the rotation speed of the robot and the current speed-dependent i.e. the rotational speed = 10 - 0.75 * getVelocity ()


Well, this issue on here myself, I will not play games but have to write games Chen, together to learn JAVA now!



Guess you like

Origin blog.csdn.net/weixin_34401479/article/details/91397376