5 errors, who can help me?

Jump to navigation Jump to search

5 errors, who can help me?

Can someone tell me the problem here?? I dont get it :S


Compiling...


1. ERROR in C:\robocode\robots\MyRobots\Yeah.java (at line 22) turnRadarRightRadians(Double.POSITIVE_INFINITY); ^^^^^^^^^^^^^^^^^^^^^ The method turnRadarRightRadians(double) is undefined for the type Yeah


2. ERROR in C:\robocode\robots\MyRobots\Yeah.java (at line 36) getHeadingRadians() + e.getBearingRadians() ^^^^^^^^^^^^^^^^^ The method getHeadingRadians() is undefined for the type Yeah


3. ERROR in C:\robocode\robots\MyRobots\Yeah.java (at line 38) - getRadarHeadingRadians(); ^^^^^^^^^^^^^^^^^^^^^^ The method getRadarHeadingRadians() is undefined for the type Yeah


4. ERROR in C:\robocode\robots\MyRobots\Yeah.java (at line 40) setTurnRadarRightRadians(Utils.normalRelativeAngle(radarTurn)); ^^^^^ Utils cannot be resolved


5. ERROR in C:\robocode\robots\MyRobots\Yeah.java (at line 43) } ^ Syntax error, insert "}" to complete ClassBody


5 problems (5 errors) Compile Failed (-1)


This is my code:

package MyRobots;


import robocode.HitRobotEvent; import robocode.Robot; import robocode.ScannedRobotEvent;

import java.awt.*;

public class Yeah extends Robot {

public void run() { // Kleuren setBodyColor(Color.black); setGunColor(Color.black); setRadarColor(Color.black); setBulletColor(Color.black); setScanColor(Color.cyan);

// ...

   turnRadarRightRadians(Double.POSITIVE_INFINITY);
   do {
       // Check for new targets.
       // Only necessary for Narrow Lock because sometimes our radar is already
       // pointed at the enemy and our onScannedRobot code doesn't end up telling
       // it to turn, so the system doesn't automatically call scan() for us
       // [see the javadocs for scan()].
       scan();
   } while (true);

}

public void onScannedRobot(ScannedRobotEvent e) {

   double radarTurn =
       // Absolute bearing to target
       getHeadingRadians() + e.getBearingRadians()
       // Subtract current radar heading to get turn required
       - getRadarHeadingRadians();

   setTurnRadarRightRadians(Utils.normalRelativeAngle(radarTurn));

   // ...

}

Gertjan1996 (talk)20:57, 21 May 2014

give me the source code And Ill Try To fix it

Tmservo (talk)21:14, 21 May 2014

package MyRobots;

import robocode.AdvancedRobot; import robocode.ScannedRobotEvent; import robocode.util.Utils;

public class Yeah extends AdvancedRobot {

public void run() {

   turnRadarRightRadians(Double.POSITIVE_INFINITY);
   do {
       scan();
   } while (true);

}

public void onScannedRobot(ScannedRobotEvent e) {

   double radarTurn =
       // Absolute bearing to target
       getHeadingRadians() + e.getBearingRadians()
       // Subtract current radar heading to get turn required
       - getRadarHeadingRadians();

   setTurnRadarRightRadians(Utils.normalRelativeAngle(radarTurn));

}

}

Gertjan1996 (talk)21:21, 21 May 2014

Nevermind, i fixed it already. Still thanks for your help

Gertjan1996 (talk)21:23, 21 May 2014

now show everyone the robot

Tmservo (talk)21:26, 21 May 2014

It now only has a radar :P

Still have to add the movement and targeting haha

Gertjan1996 (talk)21:28, 21 May 2014
Tmservo (talk)21:32, 21 May 2014

I think so, i tried Stop_And_Go and I only get one error... this is the error:

1. ERROR in C:\robocode\robots\MyRobots\Yeah.java (at line 31) setAhead(direction*36*Math.max(0,Math.signum(prevEnergy-e.getEnergy()))); ^^^^^^^^^ direction cannot be resolved to a variable

And this is the source: package MyRobots;

import robocode.AdvancedRobot; import robocode.ScannedRobotEvent; import robocode.util.Utils;

public class Yeah extends AdvancedRobot {

public void run() {

   turnRadarRightRadians(Double.POSITIVE_INFINITY);
   do {
       scan();
   } while (true);

}

static double prevEnergy = 100.0;

public void onScannedRobot(ScannedRobotEvent e) {

   double radarTurn =
       // Absolute bearing to target
       getHeadingRadians() + e.getBearingRadians()
       // Subtract current radar heading to get turn required
       - getRadarHeadingRadians();

   setTurnRadarRightRadians(Utils.normalRelativeAngle(radarTurn));

{

	//energy monitoring
 	if(getDistanceRemaining()==0.0){
	setAhead(direction*36*Math.max(0,Math.signum(prevEnergy-e.getEnergy())));

}

} } }

Gertjan1996 (talk)21:43, 21 May 2014

good because it doesn't get any easier from here

Tmservo (talk)21:47, 21 May 2014

I understand :P

The problem at the moment is that I can't solve the one problem in here

Gertjan1996 (talk)21:48, 21 May 2014
Edited by author.
Last edit: 22:01, 21 May 2014

What You Want To Do Is Say. Remember The Solution To The Error Repeatedly. And Then The Answer Will Come To You. In Other Words Rememberance

Tmservo (talk)21:52, 21 May 2014

How far are you

Tmservo (talk)21:59, 21 May 2014

Trying to find a solution for

Compiling...


1. ERROR in C:\robocode\robots\Yeah.java (at line 21) setAhead(direction*36*Math.max(0,Math.signum(prevEnergy-e.getEnergy()))); ^^^^^^^^^ direction cannot be resolved to a variable


1 problem (1 error) Compile Failed (-1)


Not able to find a solution.. :(

Gertjan1996 (talk)22:00, 21 May 2014

Read The Tutorials as CAREFULLY as possible

Tmservo (talk)22:02, 21 May 2014

Finally. Solved the problem :D Now i have a working radar and the Stop And Go movement.

Do I now only have to add the GuessFactor Targeting?

Gertjan1996 (talk)22:05, 21 May 2014

Skip Anti Gravity And Go straight To guessfactor targeting

Tmservo (talk)22:07, 21 May 2014

Where do I have to add the new class Wave Bullet?

Gertjan1996 (talk)22:18, 21 May 2014

examine this code carefully

import java.awt.geom.*;
import robocode.util.Utils;
 
public class WaveBullet
{
	private double startX, startY, startBearing, power;
	private long   fireTime;
	private int    direction;
	private int[]  returnSegment;
 
	public WaveBullet(double x, double y, double bearing, double power,
			int direction, long time, int[] segment)
	{
		startX         = x;
		startY         = y;
		startBearing   = bearing;
		this.power     = power;
		this.direction = direction;
		fireTime       = time;
		returnSegment  = segment;
	}
Tmservo (talk)22:24, 21 May 2014

I am sure this is not good, but where am i going wrong?

import robocode.AdvancedRobot; import robocode.ScannedRobotEvent; import java.awt.geom.*; import robocode.util.Utils;

public class WaveBullet { private double startX, startY, startBearing, power; private long fireTime; private int direction; private int[] returnSegment;

public WaveBullet(double x, double y, double bearing, double power, int direction, long time, int[] segment) { startX = x; startY = y; startBearing = bearing; this.power = power; this.direction = direction; fireTime = time; returnSegment = segment; }

public class Yeah extends AdvancedRobot { public void run() {

  turnRadarRightRadians(Double.POSITIVE_INFINITY);
  do {
      scan();
  } while (true);

} static double prevEnergy = 100.0; public void onScannedRobot(ScannedRobotEvent e) {

  double radarTurn =
      // Absolute bearing to target
      getHeadingRadians() + e.getBearingRadians()
      // Subtract current radar heading to get turn required
      - getRadarHeadingRadians();
  setTurnRadarRightRadians(Utils.normalRelativeAngle(radarTurn));

{ //energy monitoring

	if(prevEnergy > (prevEnergy = e.getEnergy()) && getDistanceRemaining() == 0.0);

} } }

Gertjan1996 (talk)22:27, 21 May 2014

Just compile it and see what happens

Tmservo (talk)22:31, 21 May 2014

How to solve this..

Compiling...


1. ERROR in C:\robocode\robots\Yeah.java (at line 26) public class WaveBullet ^^^^^^^^^^ The public type WaveBullet must be defined in its own file


1 problem (1 error) Compile Failed (-1)

Source code right now:

import robocode.AdvancedRobot; import robocode.ScannedRobotEvent; import java.awt.geom.*; import robocode.util.Utils;

public class Yeah extends AdvancedRobot { public void run() {

  turnRadarRightRadians(Double.POSITIVE_INFINITY);
  do {
      scan();
  } while (true);

} static double prevEnergy = 100.0; public void onScannedRobot(ScannedRobotEvent e) {

  double radarTurn =
      // Absolute bearing to target
      getHeadingRadians() + e.getBearingRadians()
      // Subtract current radar heading to get turn required
      - getRadarHeadingRadians();
  setTurnRadarRightRadians(Utils.normalRelativeAngle(radarTurn));

{ //energy monitoring

	if(prevEnergy > (prevEnergy = e.getEnergy()) && getDistanceRemaining() == 0.0);

} } }

public class WaveBullet { private double startX, startY, startBearing, power; private long fireTime; private int direction; private int[] returnSegment;

public WaveBullet(double x, double y, double bearing, double power, int direction, long time, int[] segment) { startX = x; startY = y; startBearing = bearing; this.power = power; this.direction = direction; fireTime = time; returnSegment = segment; } }

Gertjan1996 (talk)22:37, 21 May 2014

You need To make a Robot That Uses Multiple Java files

Tmservo (talk)22:39, 21 May 2014
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

You need to extend "AdvancedRobot" is all. Then it should work fine.

Ah right, a little late. Sorry about that.

Chase17:32, 25 May 2014