robocode.Bullet instances not being synchronized
← Thread:Talk:Robocode/Game Physics/robocode.Bullet instances not being synchronized/reply (2)
onHitByBullet events return bullet coordinates after it hits you, and onBulletHitBullet events return bullet coordinates before it hits the other bullet. If you reuse the same code for both events, you have to adjust time accordingly. I stumbled on this while tracking a wave detection bug in Combat a while ago.
But surely both Bullet objects should show the same location even after a hit? ie, the one from setFireBullet and the one from BulletHitBulletEvent? They both represent the same simulated object. They should stay in step with each other.
They both represent states of the same simulated object. Maybe the Bullet instance returned from setFireBullet is updated every tick while the instance returned by BulletHitBulletEvent isn't, but only debugging the Robocode engine to be sure.
I agree this is a silly bug and it sucks that it's causing you problems, but I'm kind of surprised you are using these Bullet objects this way at all. I just check if setFireBullet returns null and if it's not I mark the appropriate wave. It never even crossed my mind to store the Bullet object or use any information from it. :-)
You do not have permission to edit this page, for the following reasons:
You can view and copy the source of this page.
Return to Thread:Talk:Robocode/Game Physics/robocode.Bullet instances not being synchronized/reply (5).
Ah, that makes more sense. Indeed I do duplicate that in my own class for the gun/movement linking of bullet shadows.
(Not sure if you're joking about your focus on code size... =) jk)
At one time, I was using the bullet objects for matching things up. I stopped doing that after the bug in 1.7.3.0 where the bullet objects in the events could no longer be compared against the one from the setFire method. Now I use my own bullet objects, kind of like what Skilgannon mentioned as a possibility.
I thought this was fixed in Robocode 1.7.3.2....maybe it was, but a lot of us are still running 1.7.3.0 (in part because 1.7.3.2 is not available on the web, and newer versions are not currently supported by the Rumble). Furthermore, I thought this was the bug that broke Krabby2, but I see it's scores are not improved with 1.7.3.2 (if you look at it's history, you will see much better scores for clients from version 1.6.1.4).
At one point when I was just starting out kept the bullet object, but things didn't seem to ever match up at the time (I probably just didn't know what I was doing). So I ditched it.
So yeah, I just fudge it now too. If it is within x of a wave, and that wave is the closest, then that wave is the wave the bullet is from.
But for longest time I had this weird bug in my detection which I finally found out was an enemy firing on the same turn it died (thus I could not detect its firing). So I just kept the heat wave, which solved the problem most the time.