[Home]CoordinateMirrorMovement

Robo Home | Changes | Preferences | AllPages

Difference (from prior major revision) (minor diff)

Added: 96a97,98

An early version of Beowulf used this type of movement, but I added something that every 500 or so rounds my bot flipped copied coordiantes(never the same as the enemy though that would make a decent rammer), sometimes mirrored over X or sometimes over Y and sometimes both. It was rather effective vs anti-mirror as it picked which kind of mirror at random (though you could do something like a virtual gun, e.g. virtual movement to pick the best ways to copy and rank em or what not), I also added something that made it so my bot would flow around the enemy if it was within 20 distance. I was going to add wall smoothing(and wall advoidance of course) but by that time I had dropped the idea. (Note: its better against an anti-mirror gun, but said gun is still gonna pick it apart) --Chase-san

A type of MirrorMovement where you copy the coordinate of your opponent.

Bots using this Movement:

Sample code(stelo.MirrorNano 1.1's):

// MirrorNano
// codesize 247
// author Stelokim
package stelo;
import robocode.*;
//import java.awt.Color;
import robocode.util.Utils;
import java.util.*;
import java.awt.geom.*;

// mirror movement
public class MirrorNano extends AdvancedRobot
{
	static double centerX, centerY;
	//Point2D robotLocation;
    //Point2D enemyLocation;
    static double enemyAbsoluteBearing;
	static double lastEnemyAbsoluteBearing;
	static double enemyEnergy;
		
	public void run() {
		// After trying out your robot, try uncommenting the import at the top,
		// and the next line:
		//setColors(Color.red,Color.blue,Color.green);
		centerX = getBattleFieldWidth() / 2.0;
		centerY = getBattleFieldHeight() / 2.0;
		//enemyLocation = new Point2D.Double();
		
		//while(true) {
            turnRadarRightRadians(Double.POSITIVE_INFINITY); 
		//}
	}

	/**
	 * onScannedRobot: What to do when you see another robot
	 */
	
	public void onScannedRobot(ScannedRobotEvent e) {
		double enemyX, enemyY;
			
        //robotLocation = new Point2D.Double(myX, myY);
        enemyAbsoluteBearing = getHeadingRadians() + e.getBearingRadians();
        //enemyLocation = vectorToLocation(enemyAbsoluteBearing, enemyDistance, robotLocation);

		enemyX = getX() + Math.sin(enemyAbsoluteBearing) * e.getDistance();
		enemyY = getY() + Math.cos(enemyAbsoluteBearing) * e.getDistance();
				
		// attack
		// HeadOnTargeting
		//setTurnGunRightRadians(Utils.normalRelativeAngle(enemyAbsoluteBearing - getGunHeadingRadians()));
		// AngularTargeting
		setTurnGunRightRadians(Utils.normalRelativeAngle(enemyAbsoluteBearing - getGunHeadingRadians() + 2.0 * (enemyAbsoluteBearing - lastEnemyAbsoluteBearing)));
		
		//fire(getEnergy() * 25.0 / e.getDistance());
		fire(getEnergy() * 10.0 / e.getDistance());
		//fire(getEnergy() * 2000.0 / e.getDistance() / e.getDistance());
		lastEnemyAbsoluteBearing = enemyAbsoluteBearing;
		
		// move (StopNMirror)
		if (enemyEnergy > (enemyEnergy = e.getEnergy())) {
			//goTo(new Point2D.Double(2.0 * centerX - enemyLocation.getX(), 2.0 * centerY - enemyLocation.getY()));
			double destinationX, destinationY;

			//destinationX = 2.0 * centerX - enemyX;
			//destinationY = 2.0 * centerY - enemyY;
		
			// slightly closer to the enemy to avoid wall collision
			destinationX = 1.8 * centerX - 0.8 * enemyX;
			destinationY = 1.8 * centerY - 0.8 * enemyY;
						
	        double angle = Utils.normalRelativeAngle(Math.atan2(destinationX - getX(), destinationY - getY()) - getHeadingRadians());
		double turnAngle = Math.atan(Math.tan(angle));
	        setTurnRightRadians(turnAngle);
	
	        //setAhead(Math.sqrt((getX() - destinationX) * (getX() - destinationX) + (getY() - destinationY) * (getY() - destinationY)) * (angle == turnAngle ? 1 : -1));
	        setAhead((angle == turnAngle ? 50 : -50)); // due to code size
		}
		// Lock Radar Infinite style.  About a 99% lock rate - plus good melee coverage.
		setTurnRadarLeftRadians(getRadarTurnRemaining());			
	}
}
This bot moves such a way symmetric with respect to the battle field center point.

-- Stelokim


An early version of Beowulf used this type of movement, but I added something that every 500 or so rounds my bot flipped copied coordiantes(never the same as the enemy though that would make a decent rammer), sometimes mirrored over X or sometimes over Y and sometimes both. It was rather effective vs anti-mirror as it picked which kind of mirror at random (though you could do something like a virtual gun, e.g. virtual movement to pick the best ways to copy and rank em or what not), I also added something that made it so my bot would flow around the enemy if it was within 20 distance. I was going to add wall smoothing(and wall advoidance of course) but by that time I had dropped the idea. (Note: its better against an anti-mirror gun, but said gun is still gonna pick it apart) --Chase-san


Robo Home | Changes | Preferences | AllPages
Edit text of this page | View other revisions
Last edited October 17, 2006 19:51 EST by svr2.pace.k12.mi.us (diff)
Search: