Difference between revisions of "Robocode/Game Physics"

From Robowiki
Jump to navigation Jump to search
m
Line 5: Line 5:
 
== Robocode Game Physics ==
 
== Robocode Game Physics ==
  
=== Coordinates System ===
+
=== Coordinates and Direction Conventions ===
[[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.
+
{|border="0" style="text-align:left"
 
+
| 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.
 +
|-
 +
| 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".
 +
|}
 +
<br/>
 +
Figure 1:
 
http://www.ibm.com/developerworks/java/library/j-robocode2/fig2.gif
 
http://www.ibm.com/developerworks/java/library/j-robocode2/fig2.gif
  
 
=== Time and distance measurements in Robocode ===
 
=== Time and distance measurements in Robocode ===
{|border="0"
+
{|border="0" style="text-align:left"
| Time (t) || Robocode time is measured in "ticks". Each robot gets one turn per tick. 1 tick = 1 turn.
+
| 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.
+
| 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.
 
|}
 
|}
  

Revision as of 14:47, 28 November 2007

This article is a stub. You can help RoboWiki by expanding it.

This page describes the game physics of Robocode

Robocode Game Physics

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

Robocode Processing Loop

The order that Robocode runs is as follows:

  1. Battle view is (re)painted
  2. All robots execute their code until they take action (and then paused)
  3. Time is updated (time = time + 1)
  4. All bullets move and check for collisions
  5. All robots move (heading, accelration, velocity, distance, in that order)
  6. All robots perform scans (and collect team messages)
  7. All robots are resumed to take new action
  8. Each robot is processing its event queue

See Also