Difference between revisions of "Robocode/Game Physics"
< Robocode
Jump to navigation
Jump to search
(Added →Robot, Gun, and Radar rotation) |
(Added →Bullets) |
||
Line 7: | Line 7: | ||
== Coordinates and Direction Conventions == | == Coordinates and Direction Conventions == | ||
{|border="0" style="text-align:left" | {|border="0" style="text-align:left" | ||
− | ! Coordinates System | + | ! Coordinates System: |
| [[Robocode]] is using the [http://en.wikipedia.org/wiki/Cartesian_coordinate_system Cartesian Coordinate System], which means that that the (0, 0) coordinate is located in the buttom left of the battle field. | | [[Robocode]] is using the [http://en.wikipedia.org/wiki/Cartesian_coordinate_system Cartesian Coordinate System], which means that that the (0, 0) coordinate is located in the buttom left of the battle field. | ||
|- | |- | ||
− | ! Clockwise Direction | + | ! Clockwise Direction: |
| [[Robocode]] is using a clockwise direction convension where 0 / 360 deg is towards "North", 90 deg towards "East", 180 deg towards "South", and 270 deg towards "West". | | [[Robocode]] is using a clockwise direction convension where 0 / 360 deg is towards "North", 90 deg towards "East", 180 deg towards "South", and 270 deg towards "West". | ||
|} | |} | ||
Line 19: | Line 19: | ||
== Time and distance measurements in Robocode == | == Time and distance measurements in Robocode == | ||
{|border="0" style="text-align:left" | {|border="0" style="text-align:left" | ||
− | ! Time (t) | + | ! Time (t): |
| Robocode time is measured in "ticks". Each robot gets one turn per tick. 1 tick = 1 turn. | | Robocode time is measured in "ticks". Each robot gets one turn per tick. 1 tick = 1 turn. | ||
|- | |- | ||
− | ! Distance Measurement | + | ! 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. | | 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. | ||
|} | |} | ||
Line 28: | Line 28: | ||
== Robot Movement Physics == | == Robot Movement Physics == | ||
{|border="0" style="text-align:left" | {|border="0" style="text-align:left" | ||
− | ! Acceleration (a) | + | ! Acceleration (a): |
| Robots accelerate at the rate of 1 pixel/turn. Robots decelerate at the rate of 2 pixels/turn. Robocode determines acceleration for you, based on the distance you are trying to move. | | Robots accelerate at the rate of 1 pixel/turn. Robots decelerate at the rate of 2 pixels/turn. Robocode determines acceleration for you, based on the distance you are trying to move. | ||
|- | |- | ||
− | ! Velocity Equation(v) | + | ! Velocity Equation(v): |
| v = at. Velocity can never exceed 8 pixels/turn. Note that technically, velocity is a vector, but in Robocode we simply assume the direction of the vector to be the robot's heading. | | v = at. Velocity can never exceed 8 pixels/turn. 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) | + | ! Distance Equation (d): |
| d = vt. That is, distance = velocity * time | | d = vt. That is, distance = velocity * time | ||
|} | |} | ||
Line 48: | Line 48: | ||
! Max rate of rotation of radar: | ! Max rate of rotation of radar: | ||
| 45 deg / turn. This is added to the current rate of rotation of the gun. | | 45 deg / turn. This is added to the current rate of rotation of the gun. | ||
+ | |} | ||
+ | |||
+ | == Bullets == | ||
+ | {|border="0" style="text-align:left" | ||
+ | ! Damage: | ||
+ | | 4 * firepower. If firepower > 1, it does an additional damage = 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. | ||
|} | |} | ||
Revision as of 15:11, 28 November 2007
This article is a stub. You can help RoboWiki by expanding it. |
Robocode Game Physics
This page describes the game physics of Robocode
Contents
Coordinates and Direction Conventions
Coordinates System: | Robocode is using the Cartesian Coordinate System, which means that that the (0, 0) coordinate is located in the buttom left of the battle field. |
---|---|
Clockwise Direction: | Robocode is using a clockwise direction convension where 0 / 360 deg is towards "North", 90 deg towards "East", 180 deg towards "South", and 270 deg towards "West". |
Figure 1:
http://www.ibm.com/developerworks/java/library/j-robocode2/fig2.gif
Time and distance measurements in Robocode
Time (t): | Robocode time is measured in "ticks". Each robot gets one turn per tick. 1 tick = 1 turn. |
---|---|
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. |
Robot Movement Physics
Acceleration (a): | Robots accelerate at the rate of 1 pixel/turn. Robots decelerate at the rate of 2 pixels/turn. Robocode determines acceleration for you, based on the distance you are trying to move. |
---|---|
Velocity Equation(v): | v = at. Velocity can never exceed 8 pixels/turn. 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. That is, distance = velocity * time |
Robot, Gun, and Radar rotation
Max rate of rotation of robot: | (10 - 0.75 * abs(velocity)) deg / turn. The faster you're moving, the slower you turn. |
---|---|
Max rate of rotation of gun: | 20 deg / turn. This is added to the current rate of rotation of the robot. |
Max rate of rotation of radar: | 45 deg / turn. This is added to the current rate of rotation of the gun. |
Bullets
Damage: | 4 * firepower. If firepower > 1, it does an additional damage = 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. |
Robocode Processing Loop
The order that Robocode runs is as follows:
- Battle view is (re)painted
- All robots execute their code until they take action (and then paused)
- Time is updated (time = time + 1)
- All bullets move and check for collisions
- All robots move (heading, accelration, velocity, distance, in that order)
- All robots perform scans (and collect team messages)
- All robots are resumed to take new action
- Each robot is processing its event queue