Secrets from the Robocode masters
Steps: 1) Fresh install of Robocode into folder (manifests even in default, C:robocode) 2) Create.java,.properties, &.team file with text editor (text as seen above) in 'robots/somepackage' 3) Run robocode from the Desktop icon 4) Stop default install battle or let.
Content series:
This content is part # of # in the series: Secrets from the Robocode masters
https://www.ibm.com/developerworks/library/?series_title_by=**auto**
This content is part of the series:Secrets from the Robocode masters
Stay tuned for additional content in this series.
Factored wall avoidance
It's difficult to come up with an algorithm that keeps your bot out of the walls without getting it trapped in a corner or deviating too much from the desired movement direction. A simple solution is factored wall avoidance. In this tip, David McCoy shows you how to implement this handy technique.
It's difficult to come up with an algorithm that keeps your bot out of the walls without getting it trapped in a corner or deviating too much from the desired movement direction. A simple solution is factored wall avoidance. In this tip, David McCoy shows you how to implement this handy technique.
Anti-gravity movement
Anti-gravity movement, in its many modified forms, is the movement type of choice for most expert Robocoders. With it you can define points on the map to avoid, easily create movement patterns, and dodge enemy bullets. Alisdair Owens shows you how to implement this helpful technique.
Anti-gravity movement, in its many modified forms, is the movement type of choice for most expert Robocoders. With it you can define points on the map to avoid, easily create movement patterns, and dodge enemy bullets. Alisdair Owens shows you how to implement this helpful technique.
Predictive targeting
All successful targeting and shooting of enemy robots requires an alrogithm to fire bullets at the place where you predict that an opponent will be at a future point in time. In this tip, Simon Parker describes an algorithm that can be used for linear, circular, and oscillating predictive targeting.
All successful targeting and shooting of enemy robots requires an alrogithm to fire bullets at the place where you predict that an opponent will be at a future point in time. In this tip, Simon Parker describes an algorithm that can be used for linear, circular, and oscillating predictive targeting.
Tracking your opponents' movement
Every targeting algorithm has limitations because there will always be some movement pattern that it has difficulty predicting. Learn how to make your bot select the best movement algorithm for each opponent.
Every targeting algorithm has limitations because there will always be some movement pattern that it has difficulty predicting. Learn how to make your bot select the best movement algorithm for each opponent.
Circular targeting
Circular targeting is the next step after you've mastered linear targeting. Using slightly more advanced mathematics, this system allows you to hit robots that travel in circles with perfect accuracy, all the while retaining effectiveness against those that travel in straight lines. Alisdair Owens shows you how to implement this technique and provides an example bot to take out for a test drive.
Circular targeting is the next step after you've mastered linear targeting. Using slightly more advanced mathematics, this system allows you to hit robots that travel in circles with perfect accuracy, all the while retaining effectiveness against those that travel in straight lines. Alisdair Owens shows you how to implement this technique and provides an example bot to take out for a test drive.
Dodge bullets
To make a winning Robocode robot, you must be able to hit your opponent more than your opponent hits you. Making your robot target your opponent is a fine art, but what if your opponent couldn't target you? Using a simple trick and some guesswork, DodgeBot, listed here, shows you how to dodge bullets.
To make a winning Robocode robot, you must be able to hit your opponent more than your opponent hits you. Making your robot target your opponent is a fine art, but what if your opponent couldn't target you? Using a simple trick and some guesswork, DodgeBot, listed here, shows you how to dodge bullets.
Radar sweeps
In this tip, learn how to make the most efficient use of your robot's radar, to get the most up-to-date information on your opponents' location.
In this tip, learn how to make the most efficient use of your robot's radar, to get the most up-to-date information on your opponents' location.
Roboleague
Are you interested in setting up your own league for Robocode players? This article will tell you how Christian Schnell did it with his Roboleague.
Are you interested in setting up your own league for Robocode players? This article will tell you how Christian Schnell did it with his Roboleague.
Polymorphic enemy cache
Successful robots maintain a store of information, accessible at any time for making crucial decisions while in battle. This is useful for a variety of reasons, from enemy movement pattern analysis to determining whom to attack based on proximity and strength. This tip explains how you can implement an effective, fast enemy cache while having the convenience of an always up-to-date object using polymorphism.
Successful robots maintain a store of information, accessible at any time for making crucial decisions while in battle. This is useful for a variety of reasons, from enemy movement pattern analysis to determining whom to attack based on proximity and strength. This tip explains how you can implement an effective, fast enemy cache while having the convenience of an always up-to-date object using polymorphism.
Extensible/reusable robots
Ray Vermette describes how he breaks up his Robocode robot up into modular, reusable pieces, each managing a different aspect of the robot's behavior.
Ray Vermette describes how he breaks up his Robocode robot up into modular, reusable pieces, each managing a different aspect of the robot's behavior.
Robocode strategies
This guide to Robocode strategies reveals the genesis of the Gladiatorial League and discusses the different strategy levels of movement, shooting, and gathering information.
This guide to Robocode strategies reveals the genesis of the Gladiatorial League and discusses the different strategy levels of movement, shooting, and gathering information.
Downloadable resources
Related topic
- See IBM Bluemix in action: In this demo, David Barnes shows you how to develop, create, and deploy an application in the cloud.
Comments
Sign in or register to add and subscribe to comments.
PermalinkJoin GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign up Find file Copy path
Cannot retrieve contributors at this time
packagesample; |
importjava.awt.Color; |
importjava.awt.geom.Point2D; |
importrobocode.*; |
importrobocode.util.Utils; |
/** |
* SuperSpinBot - a Super Sample Robot by CrazyBassoonist based on the robot RamFire by Mathew Nelson and maintained by Flemming N. Larsen. |
* |
* This robot tries to ram it's opponents. |
* |
*/ |
publicclassSuperRamFireextendsAdvancedRobot { |
//These are constants. One advantage of these is that the logic in them (such as 20-3*BULLET_POWER) |
//does not use codespace, making them cheaper than putting the logic in the actual code. |
finalstaticdoubleBULLET_POWER=3;//Our bulletpower. |
finalstaticdoubleBULLET_DAMAGE=BULLET_POWER*4;//Formula for bullet damage. |
finalstaticdoubleBULLET_SPEED=20-3*BULLET_POWER;//Formula for bullet speed. |
//Variables |
staticdouble dir=1; |
staticdouble oldEnemyHeading; |
staticdouble enemyEnergy; |
publicvoidrun(){ |
//RamFire Colors |
setBodyColor(Color.lightGray); |
setGunColor(Color.gray); |
setRadarColor(Color.darkGray); |
setAdjustGunForRobotTurn(true); |
setAdjustRadarForGunTurn(true); |
setTurnRadarRightRadians(Double.POSITIVE_INFINITY); |
} |
publicvoidonScannedRobot(ScannedRobotEvente){ |
double absBearing=e.getBearingRadians()+getHeadingRadians(); |
//This makes the amount we want to turn be perpendicular to the enemy. |
double turn=absBearing+Math.PI/2; |
//This formula is used because the 1/e.getDistance() means that as we get closer to the enemy, we will turn to them more sharply. |
//We want to do this because it reduces our chances of being defeated before we reach the enemy robot. |
turn-=Math.max(0.5,(1/e.getDistance())*100)*dir; |
setTurnRightRadians(Utils.normalRelativeAngle(turn-getHeadingRadians())); |
//This block of code detects when an opponents energy drops. |
if(enemyEnergy>(enemyEnergy=e.getEnergy())){ |
//We use 300/e.getDistance() to decide if we want to change directions. |
//This means that we will be less likely to reverse right as we are about to ram the enemy robot. |
if(Math.random()>200/e.getDistance()){ |
dir=-dir; |
} |
} |
//This line makes us slow down when we need to turn sharply. |
setMaxVelocity(400/getTurnRemaining()); |
setAhead(100*dir); |
//Finding the heading and heading change. |
double enemyHeading = e.getHeadingRadians(); |
double enemyHeadingChange = enemyHeading - oldEnemyHeading; |
oldEnemyHeading = enemyHeading; |
/*This method of targeting is know as circular targeting; you assume your enemy will |
*keep moving with the same speed and turn rate that he is using at fire time.The |
*base code comes from the wiki. |
*/ |
double deltaTime =0; |
double predictedX = getX()+e.getDistance()*Math.sin(absBearing); |
double predictedY = getY()+e.getDistance()*Math.cos(absBearing); |
while((++deltaTime) *BULLET_SPEED<Point2D.Double.distance(getX(), getY(), predictedX, predictedY)){ |
//Add the movement we think our enemy will make to our enemy's current X and Y |
predictedX +=Math.sin(enemyHeading) * e.getVelocity(); |
predictedY +=Math.cos(enemyHeading) * e.getVelocity(); |
//Find our enemy's heading changes. |
enemyHeading += enemyHeadingChange; |
//If our predicted coordinates are outside the walls, put them 18 distance units away from the walls as we know |
//that that is the closest they can get to the wall (Bots are non-rotating 36*36 squares). |
predictedX=Math.max(Math.min(predictedX,getBattleFieldWidth()-18),18); |
predictedY=Math.max(Math.min(predictedY,getBattleFieldHeight()-18),18); |
} |
//Find the bearing of our predicted coordinates from us. |
double aim =Utils.normalAbsoluteAngle(Math.atan2( predictedX - getX(), predictedY - getY())); |
//Aim and fire. |
setTurnGunRightRadians(Utils.normalRelativeAngle(aim - getGunHeadingRadians())); |
setFire(BULLET_POWER); |
setTurnRadarRightRadians(Utils.normalRelativeAngle(absBearing-getRadarHeadingRadians())*2); |
} |
publicvoidonBulletHit(BulletHitEvente){ |
enemyEnergy-=BULLET_DAMAGE; |
} |
publicvoidonHitWall(HitWallEvente){ |
dir=-dir; |
} |
} |
Copy lines Copy permalink