From Robowiki
Jump to navigation Jump to search

From old wiki

Hey Skilgannon, I'm pretty sure it's right how it was. If you're going solely on the evidence of graphical debugging, be warned that it doesn't always line up with reality. Been a while since dealing with nitty gritty surf details, so I'll double check later, but pretty sure it's right as is. -- Voidious

IIRC, -1 is correct. Because you can only detect energy drop 1 round after it has happened. And -2 for the data cause thats the data the enemy used to aim, as it fires the turn after it is stated. Then again my memory is shotty, maybe Voidious can clear that up some. --Chase-san

  • Yeah, that's how it is - to the best of my recollection, anyway. =) -- Voidious

Using debug graphics I couldn't get it to line up with bullets on the waves. My score went up about 10% against DevilFISH (to 92%, with segmentation) after changing it to -2. Here's the debug code I used:

   public void onPaint(java.awt.Graphics2D g) {
         for(int i = 0; i < _enemyWaves.size(); i++){
            EnemyWave w = (EnemyWave)(_enemyWaves.get(i));
            int radius = (int)w.distanceTraveled;
            Point2D.Double center = w.fireLocation;
            if(radius - 40 < center.distance(_myLocation))
               g.drawOval((int)(center.x - radius ), (int)(center.y - radius), radius*2, radius*2);

It may have to do with the doSurfing() being in the onScannedRobot() instead of the run(), and the order of event execution, I'm not sure. -- Skilgannon

Just reviewed some things, I'm as sure as I could be that it's right with T-1. There's discussion about it on the RobocodeSG, EnemyWaves, and EnergyDrop pages. According to GamePhysics page, the battlefield draws between onScannedRobot and run - so in terms of robot performance, it doesn't matter in which you put your code, but it might for debugging graphics. Edit: Umm, duh, it still shouldn't matter as the timer doesn't advance anywhere in there. -- Voidious

Yeah, that would do it. The debug gets called before the 'advance waves', so prints with the old data. I'm still not sure why my score leapt up, though. Maybe I'll try to fix mine to call from the run() using getAllEvents(), though I don't really mind PerformanceEnhancingBugs =) -- Skilgannon

Finally found the bug that was causing my score to do better with the T-2, it had to do with my distancing. I'm now getting 97.5% vs. DevilFISH, without firing, over 500 rounds. This is with T-1. I've changed my debug code:

   public void onPaint(java.awt.Graphics2D g) {
         for(int i = 0; i < _enemyWaves.size(); i++){
            EnemyWave w = (EnemyWave)(_enemyWaves.get(i));

            int radius = (int)(w.distanceTraveled + w.bulletVelocity);
            //hack to make waves line up visually, due to execution sequence in robocode engine
            //use only if you advance waves in the event handlers (eg. in onScannedRobot())

            Point2D.Double center = w.fireLocation;
            if(radius - 40 < center.distance(_myLocation))
               g.drawOval((int)(center.x - radius ), (int)(center.y - radius), radius*2, radius*2);

Thanks for catching that, guys. Maybe it would be a good idea to add this code to BasicSurfer? -- Skilgannon

  • Oops, sorry, I forgot to comment that I think that's a good idea. Too late. =) -- Voidious

Question about wallSmoothing function

I was looking into switching out the wallSmoothing function for a more advanced one, and I was wondering if the wallSmoothing function that BasicSurfer uses uses Radians for the angle input or Degrees. --Jacob Litewski 03:06, 9 June 2009 (UTC)

Radians, you can see that it's value comes ultimately from a call to Math.atan2, which returns it's value in radians. --zyx 03:33, 9 June 2009 (UTC)


Thread titleRepliesLast modified
Simple Bullet Shadowing Surfer 915:42, 19 May 2019

Simple Bullet Shadowing Surfer

Hi, I have an idea for a bullet shadowing wave surfer robot but I don't really know how to get started. Could someone point me to a relatively easy to understand wave surfer that implements bullet shadows into its danger prediction? Thanks in advance!

Slugzilla (talk)17:55, 12 May 2019

Implementing bullet shadow in wave surfer is very easy; just set danger covered by shadow to 0

however, calculating bullet shadow is not trivial

the first bot featuring this technique is Diamond, and it’s open source!

Just have a look at it, you’ll know that better.

Xor (talk)04:49, 13 May 2019
Edited by author.
Last edit: 12:00, 18 May 2019
Both Diamond and Gilgalad use bullet shadows but IIRC Gilgalad's code was optimized for speed and made it harder to understand.
If you plan on using bullet shadows with bins(Slightly less effective), both DrussGT and WhiteFang use it.
DrussGT calculates all the shadows before hand while WhiteFang calculates them when the bullet overlaps the wave(Easier to implement and shorter code).
BTW, anybody setting wave dangers as done below?
Position danger = (bulletPassed ? 0: chanceOfBulletCollision) * dangerWithoutShadows

Edit: fix a mistake

Dsekercioglu (talk)08:51, 13 May 2019

This is not correct, although I've made the same mistake the first time thinking about this.

The catch point is that, even if your bullet passed safely, you know the intersection must contain no bullet, so the shadow of the bullet still exists

Xor (talk)06:01, 17 May 2019
Sorry, I fixed the code.
My point was: Wouldn't it be smarter to deduct (100 - x) percent of the danger if the chance of the bullet colliding is x percent.
Dsekercioglu (talk)12:01, 18 May 2019

This is incorrect, because bullet shadow has nothing to do with whether bullets collide or not — it’s all about information. You know perfectly you won’t get hit in the shadow, so danger is 0. You still get hit by the part outside of shadow in the incoming wave though.

Xor (talk)07:51, 19 May 2019
Let's say we have wave1(distanceTraveled 300) and wave2(distanceTraveled 100).
I shoot a bullet and it is calculated that it will intersect with wave2 at the x point so I set the danger to 0.
The bullet collides with the bullet that is on wave1 and the spot on wave2 isn't safe anymore.
Dsekercioglu (talk)10:19, 19 May 2019

Thanks for the input! I'll check out the code for Diamond, DrussGT, and WhiteFang later today.

Slugzilla (talk)22:49, 13 May 2019