[Home]DrussGT/HelpRequests

Robo Home | DrussGT | Changes | Preferences | AllPages

Showing revision 2
So I'm trying to get my play-it-forward working, and the standard method is working fine. However, when I tried to get the optimized version described by ABC working, it fails horribly. My hitrate against Spinbot is about the same as head on targeting, versus comparable to Shadow with the standard PlayItForward?. I've done a bit of graphical debugging and everything looks fine. If you can spot the bug/bad assumption/whatever I'd be very grateful...I've stared at this code for over 4 hours now!

// // // 	-- this method *should* be a lot faster, but I can't get it to hit spinbot, so until then....
       /*double getGunOffset(Tracer enemyStart, DCRobotState rs){
         double distance = lastScan.getDistance();
         double deltaHeading = enemyStart.heading - lastRobotScan.getHeadingRadians();
         double startAngle = rs.absBearing + deltaHeading;
         Point2D.Double myRelativeLocation = JKDCUtils.project(enemyStart.location, startAngle + Math.PI, distance);
         double bulletSpeed = 20 - 3*BULLET_POWER;
         double bulletDistance = 0;
         Tracer t = enemyStart;
         do{
            t = t.next;
            if(t == null || t.round != enemyStart.round)
               return Double.POSITIVE_INFINITY;
            bulletDistance += bulletSpeed;
         }while(JKDCUtils.sqr(bulletDistance) < myRelativeLocation.distanceSq(t.location));
            
         double fireAngle = JKDCUtils.absoluteBearing(myRelativeLocation,t.location);
         double offset = Utils.normalRelativeAngle(fireAngle - startAngle);
         if(!JKDCUtils.fieldContains(JKDCUtils.project(myLocation,rs.absBearing + offset,myRelativeLocation.distance(t.location))))
            return Double.POSITIVE_INFINITY;
      
         return offset;
      }*/
      //// The standard PlayItForward method that works perfectly, but uses a lot more Trig...
       double getGunOffset(Tracer enemyStart, DCRobotState rs){
         double bulletSpeed = 20 -3*BULLET_POWER;
         double bulletDistance = 0;
         Tracer t = enemyStart;
         Point2D.Double predLocation = enemyLocation;
         double predHeading = lastScan.getHeadingRadians();
         do{
            
            t = t.next;
            bulletDistance += bulletSpeed;
            if(!JKDCUtils.fieldContains(predLocation) || t == null || t.round != enemyStart.round)
               return Double.POSITIVE_INFINITY;
            predLocation = JKDCUtils.project(predLocation, predHeading += t.deltaHeading, t.velocity);
         	
         }while(JKDCUtils.sqr(bulletDistance) < myLocation.distanceSq(predLocation));
         double fireAngle = JKDCUtils.absoluteBearing(myLocation,predLocation);
         return Utils.normalRelativeAngle(fireAngle - rs.absBearing);
      
      }

-- Skilgannon

I can't see anything wrong with that code, have you tried it against Walls? I'm not very good at looking at other peoples code, sorry. -- ABC


Robo Home | DrussGT | Changes | Preferences | AllPages
Edit revision 2 of this page | View other revisions | View current revision
Edited December 6, 2007 10:41 EST by ABC (diff)
Search: