Fusion

From RoboWiki
Revision as of 00:12, 9 September 2013 by BeastBots101 (Talk | contribs)

Jump to: navigation, search
Fusion
Author(s) BeastBots
Extends AdvancedRobot
Targeting linear targeting
Movement Multi-Mode ramming movement
Current Version 0.2
Code License None, I don't care

Contents

Background Information

Author
BeastBots, also known as beastbots101 or EH
Extends
AdvancedRobot
What's special about it?
It's a micro rambot Multi-Mode that I made.
How competitive is it?
Not sure. I tested a bit on Impact and actually did okay. SuperRamFire was a bit pesky though.

Strategy

How does it move?
It has two forms of movement, one used for the first five rounds and the other for the rest, making it a Multi-Mode.
Drive: Go at the enemy robot with linear movement aim. Sometimes results in accidental mirror movement.
Dodge: Like stop and go but goes back and forth and gradually gets closer to the enemy. Better on bots with unsegmented linear targeting or circular targeting.
How does it fire?
Simple linear targeting from the wiki page. In the 'Drive' mode, it does not follow its bullets, the movement is like linear targeting but the rules.getBulletSpeed(bulletPower) is replaced with getVelocity(). Maybe should get rid of it.
How does it dodge bullets?
Drive method: no dodging at all. Goes straight at the enemy.
Dodge method: reacts to bullets, but not to effectively, mainly to get closer
How does the melee strategy differ from one-on-one strategy?
I doubt rambots will do well in melee battles. Maybe I'm wrong. If so, then I'll get a way to select the closest or slowest target.
What does it save between rounds and matches?
Currently nothing intentionally, but the future gun will save the average velocity between round with static long, int, and double methods.


Additional Information

Where did you get the name?
Rambots collide with the enemy, hence the name Fusion.
Can I use your code?
Yes, I don't care really what you do, just don't make a total copy and change the colors or name(or something really minor). It's the same code license as my NanoBot NightBird.
What's next for your robot?
A movement tactic to spiral around the enemy getting closer over time, like in SuperRamFire.
Linear painting
Does it have any White Whales?
Nothing really. But maybe I'll find out.
What other robot(s) is it based on?
Impact for the basic movement structure, some of the code
DodgeBot from the secrets from robocode masters site for the Dodging movement.
RamFire and SuperRamFire for the idea of rambots.


Source Code

package EH;
import robocode.*;
 
import java.awt.Color;
import java.awt.Graphics2D;
import robocode.util.Utils;
import static robocode.util.Utils.normalRelativeAngle;
import static java.lang.Math.asin;
import static java.lang.Math.sin;
 
public class Fusion extends AdvancedRobot
{
	//for direct ramming movement
	int dir=1;
	//for paint stuff
 	int scannedX = Integer.MIN_VALUE;
 	int scannedY = Integer.MIN_VALUE;
	//for evasion attack movement
	double previousEnergy = 100;
    int movementDirection = 1;
 
	public void run() {
 
		setColors(Color.gray,Color.lightGray,Color.yellow);
		setAdjustGunForRobotTurn(true);
		setAdjustRadarForGunTurn(true);
 
		while(true){
 
		turnRadarRightRadians(1);
 
		}
	}
 
	/**
	 * onScannedRobot: What to do when you see another robot
	 */
	public void onScannedRobot(ScannedRobotEvent e) {
 
     // paint stuff- see graphical debugging page on robowiki
	 //for more
 
     double angle = Math.toRadians((getHeading() + e.getBearing()) % 360);
 
     // Calculate the coordinates of the robot
     scannedX = (int)(getX() + Math.sin(angle) * e.getDistance());
     scannedY = (int)(getY() + Math.cos(angle) * e.getDistance());
	 	//gun and radar
		double enemyAbsB=
		e.getBearingRadians()+getHeadingRadians();
 
		setTurnRadarRightRadians
		(Utils.normalRelativeAngle
		(enemyAbsB - getRadarHeadingRadians()) );
 
		double bulletPower = 3;
    double headOnBearing = getHeadingRadians() + e.getBearingRadians();
    double linearBearing = headOnBearing + Math.asin(e.getVelocity() / Rules.getBulletSpeed(bulletPower) * Math.sin(e.getHeadingRadians() - headOnBearing));
    setTurnGunRightRadians(Utils.normalRelativeAngle(linearBearing - getGunHeadingRadians()));
    setFire(bulletPower);
 
		//turn to enemy
		if (getRoundNum() <= 5) {
		double headOnTurn = 
			   getHeadingRadians() + e.getBearingRadians();
 
		double linearTurn=
			   headOnTurn + asin(e.getVelocity() / getVelocity() * sin(e.getHeadingRadians() - headOnTurn));
	    setTurnRightRadians(normalRelativeAngle(linearTurn - getHeadingRadians()));
		setAhead(Double.POSITIVE_INFINITY*dir);
		}
		if (getRoundNum() >5) {
			setTurnRightRadians(e.getBearing()+90-40*movementDirection);
			double changeInEnergy = previousEnergy-e.getEnergy();
 
			if (changeInEnergy>0 && changeInEnergy<=3) {
				movementDirection=-movementDirection;
				setAhead((e.getDistance()/4+25)*movementDirection);
			}
			previousEnergy=e.getEnergy();
		}
 
	}
 
	public void onHitByBullet(HitByBulletEvent e) {
	}
 
	public void onHitWall(HitWallEvent e) {
		//move in the opposite direction
		dir=-dir;
	}	
	public void onHitRobot(HitRobotEvent e) {
		//turn gun directly at enemy
		double absB =
			getHeadingRadians() + e.getBearingRadians();
		setTurnGunRightRadians(
			normalRelativeAngle(absB-getGunHeading()));
		setAhead(10);
	}
	public void onBulletHit(BulletHitEvent e) {
		setFire(.1);
	}
	public void onPaint(Graphics2D g) {
     g.setColor(Color.yellow);
 
     g.drawLine(scannedX, scannedY, (int)getX(), (int)getY());
 
     g.fillOval(scannedX - 5, scannedY - 5, 10, 10);
 
	}
}
Personal tools