Difference between revisions of "Blue Shift"

From Robowiki
Jump to navigation Jump to search
m (format the code using <pre> tag)
Line 2: Line 2:
  
 
It is the same as {{OldWiki|BulletDoubling}} (Old Wiki)
 
It is the same as {{OldWiki|BulletDoubling}} (Old Wiki)
[[File:Blue_Shift.JPG|400px|right]]
+
[[File:Blue_Shift.JPG|thumb|200px|right|Example of waves that reach enemy at the same time]]
 
The picture to the right shows a group of waves clustered together.
 
The picture to the right shows a group of waves clustered together.
  
Line 16: Line 16:
  
 
----
 
----
 
+
<pre>
 
package wiki;
 
package wiki;
 
 
import robocode.*;
 
import robocode.*;
  
 
public class BlueShift extends AdvancedRobot
 
public class BlueShift extends AdvancedRobot
 
 
{
 
{
 
 
double turns;
 
double turns;
 +
double time;
  
double time;
 
 
 
public void run()
 
public void run()
 
 
{
 
{
 
 
setTurnRadarRightRadians(Double.POSITIVE_INFINITY);
 
setTurnRadarRightRadians(Double.POSITIVE_INFINITY);
 +
}
  
}
 
 
 
public void onScannedRobot(ScannedRobotEvent e)
 
public void onScannedRobot(ScannedRobotEvent e)
 
 
{
 
{
 
 
double absoluteBearing = e.getBearingRadians() + getHeadingRadians();
 
double absoluteBearing = e.getBearingRadians() + getHeadingRadians();
 
 
double distance = e.getDistance();
 
double distance = e.getDistance();
 
 
setTurnRightRadians(robocode.util.Utils.normalRelativeAngle(absoluteBearing - getGunHeadingRadians()));
 
setTurnRightRadians(robocode.util.Utils.normalRelativeAngle(absoluteBearing - getGunHeadingRadians()));
 
 
turns -= getTime() - time;
 
turns -= getTime() - time;
 
 
time = getTime();
 
time = getTime();
+
if (turns <= 0) {
if (turns <= 0)
 
 
 
{
 
 
 
 
time = getTime();
 
time = getTime();
 
 
turns = distance / 11;
 
turns = distance / 11;
 
 
setFire(3);
 
setFire(3);
 
+
} else {
}
 
 
else
 
 
 
{
 
 
 
setFire((distance / turns - 20) / -3);
 
setFire((distance / turns - 20) / -3);
 
 
}
 
}
 
 
}
 
}
 
 
}
 
}
 
+
</pre>
 
 
----
 
 
 
This is just a theory I had after viewing the [[Waves]] article. Please comment, add code, or expand this article.
 
 
 
[[Category:Statistical Targeting]]
 

Revision as of 04:28, 31 July 2009

Named after the Doppler Effect

It is the same as BulletDoubling (Old Wiki)

Example of waves that reach enemy at the same time

The picture to the right shows a group of waves clustered together.

How it Works

Fire a group of bullets that reach your target at the same time, either by moving the robot, changing bullet power, or a combination of both.


Concept

Use only on stationary targets (shows concept when farther away).



package wiki;
import robocode.*;

public class BlueShift extends AdvancedRobot
{
	double turns;
	double time;

	public void run()
	{
		setTurnRadarRightRadians(Double.POSITIVE_INFINITY);
	}

	public void onScannedRobot(ScannedRobotEvent e)
	{
		double absoluteBearing = e.getBearingRadians() + getHeadingRadians();
		double distance = e.getDistance();
		setTurnRightRadians(robocode.util.Utils.normalRelativeAngle(absoluteBearing - getGunHeadingRadians()));
		turns -= getTime() - time;
		time = getTime();
		if (turns <= 0) {
			time = getTime();
			turns = distance / 11;
			setFire(3);
		} else {
			setFire((distance / turns - 20) / -3);
		}
	}
}