当前位置:   article > 正文

Game Physics

game physics
Game Physics

Game Physics
Robocode Processing Loop

 

The order that Robocode runs is as follows:

  • All robots execute their code until taking action
  • Time is updated (currentTime++)
  • All bullets move and check for collisions
  • All robots move (heading, accel, velocity, distance, in that order)
  • All robots perform scans (and collect team messages)
  • The battlefield draws
Time (t)

 

Robocode time is measured in "ticks", which are equivalent to frames displayed on the screen. Each robot gets one turn per tick. 1 tick = 1 turn = 1 frame.

 

Distance Measurement

 

Robocode's units are basically measured in pixels, with two exceptions. First, all distances are measured with double precision, so you can actually move a fraction of a pixel. Second, Robocode automatically scales down battles to fit on the screen. In this case, the unit of distance is actually smaller than a pixel.

 

 

Acceleration (a)

 

Robots accelerate at the rate of 1 pixel/tick. Robots decelerate at the rate of 2 pixels/tick. Robocode determines acceleration for you, based on the distance you are trying to move.

 

Velocity Equation(v)

 

v = at. Velocity can never exceed 8. Note that technically, velocity is a vector, but in Robocode we simply assume the direction of the vector to be the robot's heading.

 

Distance Equation (d)

 

d = vt.

 

Max rate of rotation of robot

 

(10 - .75 * abs(velocity)) degrees / tick. The faster you're moving, the slower you turn.

 

Max rate of rotation of gun

 

20 degrees / tick. This is added to the current rate of rotation of the robot.

 

Max rate of rotation of radar

 

45 degrees / tick. This is added to the current rate of rotation of the gun.

 

Damage

 

4 * firepower. If firepower > 1, it does an additional 2 * (power - 1).

 

Velocity

 

20 - 3 * firepower;

 

GunHeat generated

 

1 + firepower / 5. You cannot fire if gunHeat > 0. All guns are hot at the start of each round.

 

Power returned on hit

 

3 * firepower.

 

With Another Robot

 

Each robot takes .6 damage. If a robot is moving away from the collision, it will not be stopped.

 

With a Wall

 

AdvancedRobots take Math.abs(velocity) * .5 - 1; (Never < 0)

 
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/520555
推荐阅读
  

闽ICP备14008679号