Difference between revisions of "User talk:Realmoonstruck"

From Robowiki
Jump to navigation Jump to search
Line 3: Line 3:
 
I have been trying to make  competitive Junior Robots. This the best 1 vs 1 bot I could make till now...
 
I have been trying to make  competitive Junior Robots. This the best 1 vs 1 bot I could make till now...
  
<code>
+
<syntaxhighlight>
 
package ne0n;
 
package ne0n;
  
Line 9: Line 9:
  
 
public class JuniorLinear extends JuniorRobot {
 
public class JuniorLinear extends JuniorRobot {
 
 
int moveAmount;
 
int moveAmount;
  
 
public void run() {
 
public void run() {
 
 
setColors(black, white, red, orange, purple);
 
setColors(black, white, red, orange, purple);
 
 
moveAmount = Math.max(fieldWidth, fieldHeight);
 
moveAmount = Math.max(fieldWidth, fieldHeight);
 
 
turnTo(0);
 
turnTo(0);
  
 
while (true) {
 
while (true) {
 
 
bearGunTo(90);
 
bearGunTo(90);
 
 
ahead(moveAmount);
 
ahead(moveAmount);
 
 
}
 
}
  
Line 31: Line 24:
  
 
public void onHitWall() {
 
public void onHitWall() {
 
 
bearGunTo(90);
 
bearGunTo(90);
 
 
turnRight(90);
 
turnRight(90);
 
 
}
 
}
  
 
public void onHitByBullet() {
 
public void onHitByBullet() {
 
 
turnGunTo(hitByBulletAngle);
 
turnGunTo(hitByBulletAngle);
 
 
}
 
}
  
 
public void onHitRobot() {
 
public void onHitRobot() {
 
 
if (scannedBearing > -90 && scannedBearing < 90)
 
if (scannedBearing > -90 && scannedBearing < 90)
 
 
back(100);
 
back(100);
 
 
else
 
else
 
 
ahead(100);
 
ahead(100);
  
Line 59: Line 43:
  
 
double firepower = 3d-2d*((double)scannedDistance/(double)moveAmount);
 
double firepower = 3d-2d*((double)scannedDistance/(double)moveAmount);
 
 
double bulletVelocity = 20-3*firepower;
 
double bulletVelocity = 20-3*firepower;
 
 
double offset = Math.toDegrees(Math.asin(scannedVelocity*Math.sin(Math.toRadians(scannedHeading-scannedAngle))/bulletVelocity));
 
double offset = Math.toDegrees(Math.asin(scannedVelocity*Math.sin(Math.toRadians(scannedHeading-scannedAngle))/bulletVelocity));
 
 
turnGunTo((int)(scannedAngle + offset));
 
turnGunTo((int)(scannedAngle + offset));
 
fire(firepower);
 
fire(firepower);
Line 70: Line 51:
  
 
}
 
}
 
+
</syntaxhighlight>
</code>
 
  
 
Tis moves in the same was as the Sample Walls. As the name suggests this uses simple trigonometric linear targeting. This has been able to beat all the Sample bots on 1 vs 1. But in melee Walls and SpinBot are beating me each time. I tried to implement some better movement and targeting strategies but couldn't get anything to work till now.  
 
Tis moves in the same was as the Sample Walls. As the name suggests this uses simple trigonometric linear targeting. This has been able to beat all the Sample bots on 1 vs 1. But in melee Walls and SpinBot are beating me each time. I tried to implement some better movement and targeting strategies but couldn't get anything to work till now.  
  
 
Any help will be appreciated...
 
Any help will be appreciated...
 +
 +
: I am not entirely sure on how JuniorRobots work, but if I might suggest you stick to just radians or just degrees. Looking at your code it looks to be something like a simple linear targeting implementation. Radar handling may help somewhat. &#8212; <span style="font-family: monospace">[[User:Chase-san|Chase]]-[[User_talk:Chase-san|san]]</span> 14:21, 14 July 2010 (UTC)

Revision as of 16:21, 14 July 2010

Competitive JuniorRobot

I have been trying to make competitive Junior Robots. This the best 1 vs 1 bot I could make till now...

package ne0n;

import robocode.*;

public class JuniorLinear extends JuniorRobot {
	int moveAmount;

	public void run() {
		setColors(black, white, red, orange, purple);
		moveAmount = Math.max(fieldWidth, fieldHeight);
		turnTo(0);

		while (true) {
			bearGunTo(90);
			ahead(moveAmount);
		}

	}

	public void onHitWall() {
		bearGunTo(90);
		turnRight(90);
	}

	public void onHitByBullet() {
		turnGunTo(hitByBulletAngle);
	}

	public void onHitRobot() {
		if (scannedBearing > -90 && scannedBearing < 90)
			back(100);
		else
			ahead(100);

	}

	public void onScannedRobot() {

		double firepower = 3d-2d*((double)scannedDistance/(double)moveAmount);
		double bulletVelocity = 20-3*firepower;
		double offset = Math.toDegrees(Math.asin(scannedVelocity*Math.sin(Math.toRadians(scannedHeading-scannedAngle))/bulletVelocity));
		turnGunTo((int)(scannedAngle + offset));
		fire(firepower);

	}

}

Tis moves in the same was as the Sample Walls. As the name suggests this uses simple trigonometric linear targeting. This has been able to beat all the Sample bots on 1 vs 1. But in melee Walls and SpinBot are beating me each time. I tried to implement some better movement and targeting strategies but couldn't get anything to work till now.

Any help will be appreciated...

I am not entirely sure on how JuniorRobots work, but if I might suggest you stick to just radians or just degrees. Looking at your code it looks to be something like a simple linear targeting implementation. Radar handling may help somewhat. — Chase-san 14:21, 14 July 2010 (UTC)