Difference between revisions of "Talk:BasicSurfer"

From Robowiki
Jump to navigation Jump to search
Line 50: Line 50:
  
 
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 <code>angle</code> input or Degrees. --[[User:J Litewski|Jacob Litewski]] 03:06, 9 June 2009 (UTC)
 
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 <code>angle</code> input or Degrees. --[[User:J Litewski|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. --[[User:Zyx|zyx]] 03:33, 9 June 2009 (UTC)

Revision as of 04:33, 9 June 2009

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) {
         g.setColor(Color.red);
         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) {
         g.setColor(Color.red);
         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)