2

I've just started playing robocode and I've encountered this angle problem at my first robot project. I've wright following code in order to shot enemies nearby ;

public void onScannedRobot(ScannedRobotEvent e) {

    double radarAngle ; 
    double GunZeroAngle ;
    double difference ;
    radarAngle = getRadarHeading ();
    GunZeroAngle = getGunHeading () ;
    difference = radarAngle - GunZeroAngle  ;
    System.out.print("Target :" + radarAngle + "\nZero : "+ GunZeroAngle +" \nFark : "+ Diff + " \n "+ " *********************** "+ "\n" ); 

    if (fark != 0) {
        turnGunRight (fark) ;
        fire(1);

my problem is when enemies are too far away there are dead angles that my gun can't swipe like this; enter image description here enter image description here

and here is angles which I've written to robolog ; enter image description here I guess angle differences less then 1 degree are the problem. But sample robots like "corners" can focus on target at any angle. Can someone help me ???

Capan
  • 686
  • 1
  • 14
  • 32

1 Answers1

0

You should get the heading of the scanned Robot from the

ScannedRobotEvent

Then turn your gun into that direction and fire.

Naxos84
  • 1,890
  • 1
  • 22
  • 34
  • Exactly. The problem with using the `radar` angle is that the radar is continuously moving. It might have scanned a robot on one tick and rotated on the next tick when your `onScannedRobot` method got called. – NonlinearFruit May 09 '17 at 15:57