FightCodeGame ?
And work. Thanks for the good words! I am still attempting to get caught up with a new job and such. I do intend to keep track of things a bit better though going forward and maybe even update things as time allows.
I have a nano project that is currently stalled due to issues with my installation of Robocode, but looks very promising. It has three modes of movement, two of them reacting to enemy fire, and a PM gun.
The only problem is, I can't store .5 as a char, it gets rounded down to 0. So, I had to switch to 1 stored as a char and then divided by 2 to decode the value to a double. Then it was a few bytes over, so I had to switch from WeekendObsession's gun to Moebius's gun. But, in order to have any accuracy with that, I needed to add a setAdjustGunForRobotTurn(true);
, which cost 5 bytes and still left me 2 bytes over. If you think you could help, I could post my code.
By the way, I recently helped Chase with his Talon project--a nano with MRM. But I have a feeling that there is a more effective way to implement wall avoidance...
Send me your version that has the best performance but is only a few bytes over, I might have an idea of how to shrink it... as well as a secret weapon which does the same ;-)
I didn't compile this so there may be a few minor errors. Thanks again.
/*
Epeeist v2.0.0 by Sheldor. 03/19/2013
A NanoBot with multi-mode movement and a Pattern Matching gun.
Codesize: ??? Bytes without any colors.
Epee (pronounced aay-pay) is one of the three forms of modern sport fencing,
along with Foil and Sabre. http://en.wikipedia.org/wiki/Epee
Credits:
Pattern Matching code from simonton.WeekendObsession_S and mld.Moebius,
and a general thanks to all open source bot authors and contributors to the RoboWiki.
Epeeist is open source and released under the terms of the RoboWiki Public Code License (RWPCL) - Version 1.1
see license here: http://robowiki.net/wiki/RWPCL
*/
package sheldor.nano;
import robocode.*;
import robocode.util.Utils;
public class Epeeist extends AdvancedRobot
{
//Global variables.
static double direction;
static double enemyEnergy;
static int deathCount;
//En garde!
public void run()
{
//setAdjustGunForRobotTurn(true);
//Start spinning radar and initialize direction to infinity.
setTurnRadarRightRadians(direction = Double.POSITIVE_INFINITY);
}
public void onScannedRobot(ScannedRobotEvent e)
{
//Local variables.
int matchLength = 30;
double absoluteBearing;
double distance;
int i;
int index;
//Oscillating/Random movement.
if (enemyEnergy > (enemyEnergy = e.getEnergy()))
//if((enemyEnergy - (enemyEnergy = e.getEnergy())) > (Math.round(Math.random() * chancesOfReversing.charAt(deathCount)) * 111))
//if( (char) ((enemyEnergy - 1.09 - (enemyEnergy = e.getEnergy()))) < 2)
{
direction *= (chancesOfReversing.charAt(deathCount) - Math.random());
//direction *= (chancesOfReversing.charAt(deathCount) - (Math.random() * 2));
}
setAhead(direction);
//Stay perpendicular to the enemy.
setTurnRightRadians(Math.cos(absoluteBearing = e.getBearingRadians()) + ((160 - (distance = e.getDistance())) * (getVelocity() / 2500)));
//Pattern Matching.
/*enemyHistory = String.valueOf((char) (e.getVelocity() * (Math.sin(e.getHeadingRadians() - (absoluteBearing += getHeadingRadians()))))).concat(enemyHistory);
// search for a match
while((matchPosition = enemyHistory.indexOf(enemyHistory.substring(0, integer--), 14)) < 0);
// calculate aim offset
integer = 14;
do { absoluteBearing += ((short) enemyHistory.charAt(--matchPosition)) / 160; } while (--integer > 0);*/
//Pattern Matching
enemyHistory = String.valueOf((char)(e.getVelocity() * Math.sin(e.getHeadingRadians() - (absoluteBearing += getHeadingRadians())))).concat(enemyHistory);
while((index = enemyHistory.indexOf(enemyHistory.substring(0, matchLength--), (i = (int)(distance / 12.5)))) < 0);
do
{
absoluteBearing += (short)enemyHistory.charAt(index--) / distance;
}while(--i > 0);
//Aim at the predicted target.
setTurnGunRightRadians(Utils.normalRelativeAngle(absoluteBearing - getGunHeadingRadians()));
//Fire!
setFire(2.5);
//Infinite radar lock.
setTurnRadarLeftRadians(getRadarTurnRemainingRadians());
}
public void onDeath(DeathEvent e)
{
deathCount++;
}
public void onHitWall(HitWallEvent e)
{
//Reverse direction when the bot hits a wall.
direction = -direction;
}
static String chancesOfReversing = ""
+ (char) 1 + (char) 0 + (char) 1 + (char) 0
+ (char) 1 + (char) 0 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5
+ (char) .5 + (char) .5 + (char) .5 + (char) .5;
//Preloaded log of enemy movements for pattern matcher.
static String enemyHistory = ""
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 2
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char)-1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char) 1 + (char) 1 + (char) 1
+ (char) 1 + (char)-2 + (char)-4 + (char)-6
+ (char)-8 + (char)-8 + (char)-8 + (char)-8
+ (char)-8 + (char)-8 + (char)-8 + (char)-8
+ (char)-8 + (char)-8 + (char)-8 + (char)-8
+ (char)-8 + (char)-8 + (char)-8 + (char)-8
+ (char)-8 + (char)-8 + (char)-8 + (char)-8
+ (char)-8 + (char)-8 + (char)-8 + (char)-8
+ (char)-8 + (char)-8 + (char)-8 + (char)-8
+ (char)-8 + (char)-8 + (char)-8 + (char)-8
+ (char)-8 + (char)-8 + (char)-8 + (char)-8
+ (char)-8 + (char)-8 + (char)-8 + (char)-8
+ (char)-7 + (char)-6 + (char)-5 + (char)-4
+ (char)-3 + (char)-2 + (char)-1 + (char)1
+ (char) 2 + (char) 4 + (char) 6 + (char) 8
+ (char) 8 + (char) 8 + (char) 8 + (char) 8
+ (char) 8 + (char) 8 + (char) 8 + (char) 8
+ (char) 8 + (char) 8 + (char) 8 + (char) 8
+ (char) 8 + (char) 8 + (char) 8 + (char) 8
+ (char) 8 + (char) 8 + (char) 8 + (char) 8
+ (char) 8 + (char) 8 + (char) 8 + (char) 8
+ (char) 8 + (char) 8 + (char) 8 + (char) 8
+ (char) 8 + (char) 8 + (char) 8 + (char) 8
+ (char) 8 + (char) 8 + (char) 8 + (char) 8
+ (char) 8 + (char) 8 + (char) 8 + (char) 8
+ (char) 7 + (char) 6 + (char) 5 + (char) 4
+ (char) 3 + (char) 2 + (char) 1 + (char) 1;
}
I'll look at this a bit tonight. There is a savings that can be had by compiling with a different Java compiler. I remember that :)
Thanks.
Skilgannon has already addressed the issue on another talk page, but I would appreciate any help I can get.
BTW, I still feel very that LBB is a pretty cheezy bot. Abusing tables like that probably shouldn't be fair. It takes hours and hours though to get each bot optimized so maybe that makes it a little better overall. besting Moebius is a better accomplishment. At least he doesn't cheat...