1

I'm extending an open-source AdvancedRobot in Robocode. That robot uses setFire to shoot, but never calls execute (doesn't appear in the code). I'm wondering how it's possible to still be able to shoot (it does). SetFire's doc says : This call returns immediately, and will not execute until you call execute() or take an action that executes. I have no idea what "take an action that executes" mean. Even better, what does "action" mean ?

My main goal was to do something every time a bullet is fired, so I have overridden the fire and fireBullet methods, but that doesn't work with the "set" methods (since it's possible to call it several times, ovveriding the previous order each time and shooting only when you "call execute() or take an action that executes"). So, maybe there is a way around.

Whatever, I'd be glad if anyone could help on any of those concerns.

Thank you very much.

LogicalKip
  • 514
  • 4
  • 13

1 Answers1

0

This question sure is old, but for future reference:

Actions that execute are basically "stuff the robot can do that doesn't start with set", like fire or ahead, and so on. Calling any of these will also execute.

If you want to do something special every time a bullet is fired, you can use the following:

if (setFireBullet(someBulletPower) != null) {
    // you only land here when a REAL bullet is fired,
    // that is, when the gun heat was down.
}

Of course this only works if the open source bot you're extending is executing (it seems to be doing that, though I can't be sure if it is doing this every turn without knowing the code).

InvisiblePanda
  • 1,589
  • 2
  • 16
  • 39