[Home]BotBuilding/Tips2

Robo Home | BotBuilding | Changes | Preferences | AllPages

Here are some general 'milestones' that were important (to me) along the way:

  1. Develop a debugging system. Be able to print some text as you go and some all at once at the end. Steal someone's file writing code and make it a debugging option.
  2. Predict what your bot's position, heading, and velocity will be next turn based on this turn's instructions.
  3. Develop a crude movement style.
  4. Develop a crude wall avoidance algorithm.
  5. Develop a crude enemy scan data structure.
  6. Review some basic trigonometry.
  7. Make your turret lock on to your enemy's position. Test it in all 4 quadrants.
  8. Make your radar lock on to your enemy's position, sweeping 22.5 degrees to either side of it.
  9. Fire your gun straight ahead and hit a sitting target.
  10. Predict where your enemy's position will be if he keeps going straight ahead at his present speed for n turns.
  11. Determine if a bullet fired now could hit the target at turn n, limited to 11.0~19.7 distance/tick (min/max bullet velocity).
  12. Hit your target using linear projection.
  13. Adjust your prediction slightly to account for your bullet not actually firing until after you and your target have been moved one tick.
  14. Improve your enemy scan data structure to include one additional scan history.
  15. Predict where your enemy's position will be if he keeps changing heading at the same rate at his present speed for n turns.
  16. Hit your target using circular projection.

You should now be able to beat all sample robots.

I put debugging first because it's that important. Some things I did that you may want to implement:

-- Martin Alan Pedersen

Q: How does firing at an opponent work?

A: Letís start with a basic example: Turn 29, you instruct your gun to turn x degrees / radians. Turn 30, you instruct your gun to fire. Turn 31, your gun fires.

Now letís give some context to all of that. The instruction to fire is processed before the instructions to move or turn your gun. This means that you cannot aim and fire in the same turn, so you must aim one turn and fire the next. Your tank will also move once before firing (the same turn you are aiming). Your opponent will also be moving while you are aiming, possibly changing speed and heading. Your data will always be one turn old between deciding where to shoot and shooting.

Second illustration: In turn 29, you receive a ScannedRobotEvent, and use the data to determine the enemy robotís position. Afterward, using your movement strategy, you determine where your own robot should go and what position it will be in turn 30 as a result of movement instructions. Analyzing your opponents position and behavior, you decide what bullet power to use and angle to fire at from your future (Turn 30) position. To conclude turn 29, you tell the AdvancedRobot super class to set the throttle (Ahead) and adjust the tankís chassis, gun, and radar headings, concluding with the execute() blocking call.

In turn 30, you receive another ScannedRobotEvent, decide where to move, and how to aim (since you may as well keep aiming to keep your gun close to where it will need to be when you can fire again). To conclude turn 30, in addition to the previous instructions, you call setFire with the bullet power chosen in Turn 29.

On the server side of Turn 31 (before you are returned control of your robot), the new bullet is fired from your cool gun and travels one bulletVelocity (translated from bulletPower) length, and all other bullets are also moved. Then all bot position and chassis heading changes are processed. Then guns are rotated, and finally radars, resulting in ScannedRobotEvents for Turn 31.

-- Martin Alan Pedersen


[Along the lines of debugging, I would also add a couple key things from my experiences:

-- Voidious


Robo Home | BotBuilding | Changes | Preferences | AllPages
Edit text of this page | View other revisions
Last edited January 7, 2008 23:38 EST by Martin Alan Pedersen (diff)
Search: