View source for User talk:Gertjan1996

From Robowiki
Jump to navigation Jump to search

Contents

Thread titleRepliesLast modified
5 errors, who can help me?2416:33, 25 May 2014
I have to make a 1v1 robot220:13, 21 May 2014

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)19:57, 21 May 2014

give me the source code And Ill Try To fix it

Tmservo (talk)20: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)20:21, 21 May 2014

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

Gertjan1996 (talk)20:23, 21 May 2014

now show everyone the robot

Tmservo (talk)20:26, 21 May 2014

It now only has a radar :P

Still have to add the movement and targeting haha

Gertjan1996 (talk)20:28, 21 May 2014
 
 
 
 

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

Ah right, a little late. Sorry about that.

Chase16:32, 25 May 2014
 

I have to make a 1v1 robot

You do not have permission to edit this page, for the following reasons:

  • The action you have requested is limited to users in the group: Users.
  • You must confirm your email address before editing pages. Please set and validate your email address through your user preferences.

You can view and copy the source of this page.

 

Return to Thread:User talk:Gertjan1996/I have to make a 1v1 robot.

Its for school by the way

Gertjan1996 (talk)19:36, 21 May 2014

http://robowiki.net/wiki/One_on_One_Radar

/*******************************************************************************
 * Copyright (c) 2001-2014 Mathew A. Nelson and Robocode contributors
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://robocode.sourceforge.net/license/epl-v10.html
 *******************************************************************************/
package sample;


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

import java.awt.*;


/**
 * Walls - a sample robot by Mathew Nelson, and maintained by Flemming N. Larsen
 * <p/>
 * Moves around the outer edge with the gun facing in.
 *
 * @author Mathew A. Nelson (original)
 * @author Flemming N. Larsen (contributor)
 */
public class Walls extends Robot {

	boolean peek; // Don't turn if there's a robot there
	double moveAmount; // How much to move

	/**
	 * run: Move around the walls
	 */
	public void run() {
		// Set colors
		setBodyColor(Color.black);
		setGunColor(Color.black);
		setRadarColor(Color.orange);
		setBulletColor(Color.cyan);
		setScanColor(Color.cyan);

		// Initialize moveAmount to the maximum possible for this battlefield.
		moveAmount = Math.max(getBattleFieldWidth(), getBattleFieldHeight());
		// Initialize peek to false
		peek = false;

		// turnLeft to face a wall.
		// getHeading() % 90 means the remainder of
		// getHeading() divided by 90.
		turnLeft(getHeading() % 90);
		ahead(moveAmount);
		// Turn the gun to turn right 90 degrees.
		peek = true;
		turnGunRight(90);
		turnRight(90);

		while (true) {
			// Look before we turn when ahead() completes.
			peek = true;
			// Move up the wall
			ahead(moveAmount);
			// Don't look now
			peek = false;
			// Turn to the next wall
			turnRight(90);
		}
	}

	/**
	 * onHitRobot:  Move away a bit.
	 */
	public void onHitRobot(HitRobotEvent e) {
		// If he's in front of us, set back up a bit.
		if (e.getBearing() > -90 && e.getBearing() < 90) {
			back(100);
		} // else he's in back of us, so set ahead a bit.
		else {
			ahead(100);
		}
	}

	/**
	 * onScannedRobot:  Fire!
	 */
	public void onScannedRobot(ScannedRobotEvent e) {
		fire(2);
		// Note that scan is called automatically when the robot is moving.
		// By calling it manually here, we make sure we generate another scan event if there's a robot on the next
		// wall, so that we do not start moving up it until it's gone.
		if (peek) {
			scan();
		}
	}
}
Tmservo (talk)19:51, 21 May 2014