View source for User talk:Gertjan96

From Robowiki
Jump to navigation Jump to search

Contents

Thread titleRepliesLast modified
Simple robot - improvements, help wanted?306:14, 19 June 2014
Simple robot - looking for improvements120:59, 17 June 2014

Simple robot - improvements, help wanted?

Edited by 2 users.
Last edit: 06:14, 19 June 2014

Hello,

I have to hand my teacher the robotcode code for my robot next wednesday. It doesn't have to be a very difficult robot, so I have made this robot today. Against the sample robots, it wins against the most of them, but not all of them.

Is there anyone who can help me to improve this code? Here is the code:

package MyRobots;
import robocode.*;
import java.awt.Color;

public class Fireintheass extends AdvancedRobot
{
	double distance = 10;
	
	public void run() {
		setColors(Color.pink, Color.pink, Color.pink, Color.white, Color.pink);
		
		setAdjustRadarForGunTurn(true);
	
		setTurnRadarRight(360);
	
		while(true) {
			ahead(distance + 100);
			back(distance);
		}
	}

	public void onScannedRobot(ScannedRobotEvent e) {
		turnRight(e.getBearing());
		
		distance = e.getDistance();
		
		if (e.getVelocity() == 0)
		{
			fire(3);
		}
	
		setTurnRadarRight(360);
	}	
}
Gertjan96 (talk)19:08, 15 June 2014

Anyone? :(

Gertjan96 (talk)20:32, 15 June 2014

Need help

Gertjan96 (talk)20:40, 15 June 2014

You Should Use The Syntax Highlight Tag </syntaxhighlight>

Tmservo (talk)20:22, 16 June 2014
 
 
 

Simple robot - looking for improvements

Hello,

I made a simple but (I hope) effective robot. I don't have much experience, so I would love to get any tips on how to further improve this code. It has to be ready in 3,5 hours. Lots of thanks.

package MyRobots;
import robocode.*;
import java.awt.Color;

public class Fireintheass extends AdvancedRobot
{
	double distance = 10;
	
	public void run() {
		setColors(Color.pink, Color.pink, Color.pink, Color.white, Color.pink);
		
		setAdjustRadarForGunTurn(true);
	
		setTurnRadarRight(360);
	
		while(true) {
			ahead(distance + 100);
			back(distance);
		}
	}

	public void onScannedRobot(ScannedRobotEvent e) {
		turnRight(e.getBearing());
		
		distance = e.getDistance();
		
		if (e.getVelocity() == 0)
		{
			fire(3);
		}
	
	setTurnRadarRight(360);
	}
	
}
Gertjan96 (talk)19:30, 17 June 2014

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:Gertjan96/Simple robot - looking for improvements/reply.