Difference between revisions of "User:AW/guideToRobocode"

From Robowiki
Jump to navigation Jump to search
(Fix link)
m (→‎Bullets: hem)
Line 25: Line 25:
 
#When a bullet hits an enemy, the firing robot receives a bonus in energy of 3 * bulletPower.
 
#When a bullet hits an enemy, the firing robot receives a bonus in energy of 3 * bulletPower.
 
#When two bullets collide, both of them are destroyed.
 
#When two bullets collide, both of them are destroyed.
#When a robot hits the wall, it is destroyed.
+
#When a bullet hits the wall, it is destroyed.
  
 
===Radar===
 
===Radar===

Revision as of 22:54, 7 March 2013

The rules of the game

In robocode 1v1, there are two robots fighting on a 600 by 800 pixel battlefield. Pixels are measured from the bottom left, as in a Cartesian coordinate system. Each robot starts with a certain amount of energy (usually 100 energy). When the energy runs out, the robot dies. The objective is to destroy the enemy by as large a margin as possible.

To do this, robots have certain:

Abilities

  1. Move forwards or backwards at up to 8 pixels per turn (a turn in robocode is also called a tick)
  2. Accelerate at up to 1 pixel per turn squared
  3. Deccelerate at up to 2 pixels per turn squared
  4. Turn their body at up to (10 - 0.75 * abs(velocity)) degrees peer turn and get their orientation (relative to "north" on the battle field, going clockwise like a compass.)
  5. Turn their gun at up to 15 degrees per turn and get their gun's orientation relative to the body of the tank
  6. Turn their radar at up to 45 degrees per turn and get the radar's orientation
  7. Fire bullets ranging with powers ranging from 0.1 to 3.0
  8. Firing bullets creates gun heat of 1 + firePower / 5.0; if gunHeat > 0, the robot cannot fire.
  9. A robot's hit box is a non-rotating square. Each side is 36 pixels in length.

Bullets

  1. Firing a bullet costs energy equal to the power of the bullet;
  2. A bullet has a velocity of 20 - 3 * bulletPower;
  3. When a bullet hits, it does 4 * firePower damage to an enemy robot if firePower < 1;
  4. if firePower >= 1 the bullet does 4 * firepower + 2 * (firePower - 1). You cannot be hit by your own bullets.
  5. When a bullet hits an enemy, the firing robot receives a bonus in energy of 3 * bulletPower.
  6. When two bullets collide, both of them are destroyed.
  7. When a bullet hits the wall, it is destroyed.

Radar

A robot can receive the following information about his enemy via radar:

  1. Enemy's heading (the heading is the direction the robot is facing, this is measured from );
  2. Enemy's distance;
  3. Enemy's bearing (the angle from our heading to the enemy);
  4. Enemy's speed;
  5. Enemy's energy;

Robot collisions

  1. If a robot hits a wall, the robot stops instantly and takes damage equal to abs(velocity) * 0.5 - 1 if abs(velocity) > 2.0
  2. If a robot hits another robot, it takes 0.6 damage and instantly stops if it is moving towards the other robot.

And one final bit of details:

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. This includes firing bullets.
  5. All robots move (gun, radar, heading, acceleration, 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 processes its event queue.


That's it. You now know how robocode works. If you ever need to refresh your memory, you can go to the Physics page.

Strategy

Given the above abilities, how do you destroy the other robot? Over the years, several techniques have developed.

Here are the key concepts:

Waves

Give information from Waves.

Guess Factors

Give information from GF

Waves and guess factors are at the core of top robots.

Theory of Targeting

Theory of Movement