Will onRobotDeath event miss due to skipped turns?

Jump to navigation Jump to search

Will onRobotDeath event miss due to skipped turns?

onRobotDeath is crucial when dealing with multiple enemies. If this event were able to lost, it will be hard to guess that information back.

Xor (talk)17:47, 29 December 2017
If I understood correctly skipped turns happen when the bots passes the time limit. I think, after this event no actions are made(setAhead( ), setFire( etc.) and no events are called after it. I am 99 percent sure that if you call onRobotDeath first no skipped turns will harm it.
Even if it stopped everything you did by not updating the robot, static variables wouldn't change.
Dsekercioglu (talk)19:17, 29 December 2017

I think all events (except the skip turn event) are lost when robocode punishes for long CPU use. I have no source confirmation for it. But I quite sure that event of enemy death can be lost. I recall adding a special check of enemy not being scanned for something like 10 tics to put it into the dead enemy category because, because I was occasionally missing the death event during the run. I also think you might even miss your own death event. I have a code which suppose to print some stats at such event, and I see that sometimes the output is not produced.

Beaming (talk)04:50, 30 December 2017

Yes, that's true. I did a quick experiment and found that onRobotDeath event do lost when experiencing heavy skipped turns.

So just add if (Math.random() < 0.7) { return; } in onRobotDeath and see whether your bot totally breaks.

Xor (talk)06:02, 30 December 2017

Anyway, I see some alive bot not getting scanned for 10+ ticks (when you skip turns, that could be easy to happen), are you handling this case correctly?

Xor (talk)06:06, 30 December 2017

It should no be a problem if a "robot" reappear on scan, it is added back to the alive pool.

Hm, I could not find the code which is in charge of it. I vividly remember programming it several years ago. This might explain some quirks which I saw in melee, when my bot fires into a dead bot last seen location. I.e. if I miss robot death event, I still count enemy alive for quite a bit and keep firing at the "gost" till some timer expires.

Beaming (talk)06:34, 30 December 2017

well, firing at some "ghost" when missing onRobotDeath is unavoidable. Anyway we could set different timer for radar & gun. e.g. for radar, choose 8k ticks, where k is large enough to avoid marking alive bots as dead. And for guns, use a small k, e.g. 1, to avoid shooting at targets that we don't have new information.

Xor (talk)07:06, 30 December 2017

Just found that even onDeath can be missed, via either calling execute before it's fired (via experiment result) or skipping turns (guess, but I'm pretty sure).

And when onDeath event is missed, SYSTEM: *** has dead will also be missed.

Xor (talk)10:23, 30 December 2017

I actually meant, if you call onDeath first and do not skip any turns in it it won't be lost. I am pretty sure that there can't be any skipped turns in onDeath.

Dsekercioglu (talk)19:46, 30 December 2017

It is still possible that you miss the turn the onDeath is created for by skipping from a previous turn.

Skilgannon (talk)01:01, 31 December 2017

Even onRobotDeath event got missed, it takes at most 8 ticks (assuming radar not affected by gun/body) to recover that event

— just check if everyone else got scanned after getOthers() drops, if so, simply mark it as dead.

Xor (talk)14:43, 6 January 2018