Resources
–Robocode Official Homepage: http://robocode.sourceforge.net/
•Install
–Install JDK1.6+ (or setup your JAVA_HOME instead.)
–Download the latest version of jar file.
–Execute “java.exe –jar [the downloaded jar file]” to install.
How to Debug
•Standard Java IO
–Use System.out to print out log messages.
–Click the Tank button in battle window, log window for the Tank will be popped up automatically.
•IDE’s debug functionalities.
–Set break-points in source code.
–Start Robocode UI in IDE with debug mode.
•Painting in the battle window
–Listen paint event in source code: override onPaint method.
–Click Tank log window in battle window, and click “paint” button to activate paint mode.
Anatomy: Battle Field
•Battle Field is:
–The main area which tanks could fight.
–A 2D rectangle area to limit tanks movement.
–You can decide which tanks join the battle.
–No blockers in the battle field.
•For all tanks in the same battle field
–They share the same one boundary of fight area.
–They share same rules of battle (ticks, speed, cool time, and so on.).
–They will be located by Battle Field Manager at random location when battle starts.
Coordinates and direction
•The coordinate system is same as our nature coordinate system.
•Degree of direction are positive, it from 0 to 360.
•Comparing with our nature direction system, there are 90 degree difference (Nature = 90-Robocode+360).
Terms
•Heading
–absolute angle in degrees with 0 facing up the screen, positive clockwise. 0 <= heading < 360.
•Bearing
–relative angle to some object from your robot's heading, positive clockwise. -180 < bearing <= 180
•Turn/Tick
–Robocode time is measured in "ticks". Each robot gets one turn per tick. 1 tick = 1 turn
•Distance
–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.
•Location
–A simple (x,y) pair according to the coordinates system.
Anatomy: Tank
•One Tank is:
–An instance of one class which inherit from robocode.Robot, no matter it inherits directly or indirectly.
–A independency thread in the JVM of Robocode UI.
–An “robot”, which means all decision should be made by the class itself (source code control).
–No interaction allowed unless in debug mode.
•Tank has 3 components:
–Body
•Carries the gun with the radar on top. The body is used for moving the robot ahead and back, as well as turning left or right.
•(10 - 0.75 * abs(velocity)) deg / turn. The faster you're moving, the slower you turn.
–Gun
•Mounted on the body and is used for firing energy bullets. The gun can turn left or right.
•20 deg / turn. This is added to the current rate of rotation of the robot.
–Radar
•Mounted on the gun and is used to scan for other robots when moved. The radar can turn left or right. The radar generates onScannedRobot events when robots are detected.
•45 deg / turn. This is added to the current rate of rotation of the gun.
Speeds
•Acceleration (a):
–Robots accelerate at the rate of 1 pixel/turn/turn. Robots decelerate at the rate of 2 pixels/turn/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
Energy
–Life indicator, Tank dies when life is 0.
–Power for fire
–Add some energy when your bullet hit another tank.
–Reduce some when met collisions or hit by another tank.
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.
Collisions
–With Another Robot: Each robot takes 0.6 damage. If a robot is moving away from the collision, it will not be stopped.
–With a Wall: AdvancedRobots take abs(velocity) * 0.5 - 1; (Never < 0).
References
•Factored wall avoidance因数避墙法
•Robocode Rumble: 冠军的技巧
•Robocode 高手的秘诀:圆周瞄准
•在Robocode中使用Vector实现敌人列表
•世界robocode机器人的四大运动方式分析
•Robocode 参数大揭密
•Rock 'em, sock 'em Robocode: Round 2
•Robocode优化及性能提高
•http://robowiki.net/wiki/Robocode
•Robocode 高手的秘诀:躲避子弹