Difference between revisions of "Blue Shift"

From Robowiki
Jump to navigation Jump to search
m (format the code using <pre> tag)
(deleted - and moved to chase bullets)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Named after the [[wikipedia:Doppler effect| Doppler Effect]]
 
  
It is the same as {{OldWiki|BulletDoubling}} (Old Wiki)
 
[[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.
 
 
== 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).
 
 
 
----
 
<pre>
 
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);
 
}
 
}
 
}
 
</pre>
 

Latest revision as of 16:46, 17 June 2012