Welcome to Robocode (and the Wiki). Kick his fanny. -- Martin (My first thought was that this was a post about artificial neural networks.)
Hey, welcome to the wiki! Good luck with your first bot. --wcsv
He won't stand a chance against what i'm building! But of course its not all self made code. I'm basing parts off some of the wiki bots. Like BasicSurfer and so on. -- Ann
Welcome to the Wiki, Ann. I think you might be our first female wiki citizen. =) I'd suggest starting with something a little simpler than BasicSurfer, that's pretty tough stuff to tackle before you've had much time to get familiar with Robocode. Starting out by writing a LinearTargeting gun, then moving to a GuessFactor gun might be a better way to get warmed up. Be sure to let us know if you want help with anything. Voidious and I are often on on AIM, but the best place place to ask for help is probably on the wiki... unless you want to keep it a secret from your brother. ;-) Good luck! --David Alves
I'm the only girl? I feel so like a nerd now. Oh well, anyway, considering I have to kidnap his computer to do it (mine is to old to run anything quickly), i'm pretty sure he will know what i'm doing. I'll look into linear guns (which so happens I found a class called project in BasicSurfer, which will help with that). -Ann
Hi, Ann. Welcome to the wiki! I'd suggest making NanoBots. Although that may seem too restrictive and tough at a glance, that helps learning robocode mechanics and clear meanings. -- Stelokim
Welcome to this 'nerdy' wiki. Kawigi has made an excellent ExtendsRobot called Girl, but I don't think that that counts. It seems a good idea to start with something easy like RandomMovement and LinearTargeting, just to understand the basics and the behaviour of Robocode. You will probably pick up things a lot faster than I did, so in a few weeks I'll expect at least a top-100 bot from you! -- GrubbmGait
Welcome from me too! WaveSurfing is surely not the easiest way to get started, but if you're up for some serious WaveSuffering, knock yourself out :P I second Martin's comment that making CodeSize restricted bots might be a bad idea, but I would recommend using them as opponents to test against when you start, because they are limited in features while still often good overall bots. And don't worry, you don't have to be a girl to feel nerdy for programming tanks in your spare time... -- Voidious
You bet I will, i'll be in the top 100 in no time! Nothing's gonna stop me. I already got a linear gun working. Chase wants me off his computer now, since i'v been on it all day. ^-^ --Ann
The guess factor gun was harder then I thought it would be, but i'll try to get it working. --Ann
My guessfactor didn't work out, so instead i'm trying to get a pattern matcher working. --Ann
Help! It doesn't work, what went wrong?
//Log settings for pattern matcher. static final int maxLogSize = 500; static final int patternSize = 7; static Vector patternLog = new Vector(); //////////// Setup //////////// // Here we set up most of the general data used later. double absoluteBearingToEnemy, distanceToEnemy, energyOfEnemy; double a; int i, j; absoluteBearingToEnemy = e.getBearingRadians() + getHeadingRadians(); distanceToEnemy = e.getDistance(); energyOfEnemy = e.getEnergy(); myLocation = new Point2D.Double(getX(), getY()); Point2D.Double locationOfEnemy = project(myLocation, absoluteBearingToEnemy, distanceToEnemy); //////////// Gun //////////// // The gun is unfinished, but will be pattern matching // First we need to log the current move //Define all the viarables were going to use. double heading, velocity, angle, testScore, bestScore; angle = 0; //this way if we don't find one, it will just fire right on. heading = e.getHeadingRadians(); velocity = e.getVelocity(); //I use a point2D so I don't have to make a new class to contain the data. Point2D.Double current = new Point2D.Double(heading, velocity); //Add this data into the 0 position of the Vector patternLog.add(0, current); //this is here to remind me //0 = current move //1 = last turn //2 = 2 turns ago //etc //only do the testing if the size of the log of data is larger then the amount of data we need to test. if(patternLog.size() > patternSize+1) { //I set this to infinity so that it will test and assign non-zero locations. bestScore = Double.POSITIVE_INFINITY; //start at the pattern size plus one because everything below that point is the current data. //Now we test it till it is 1 less then the max log size // or until 1 less then the current log size // that way we will have a future value to assign the direction too. // but now that Ilook at it I realize that since 0 is the latest data, // that this is only wasting space but // won't cause it to not function correctly. for(i = patternSize+1; i < maxLogSize-1 && i < patternLog.size()-1; i++) { //we set both the testScore and the testAngle to zero so that we can get //reliable data out of them. testScore = 0; testAngle = 0; //we start this for at 1 because otherwise it won't have enough.. back history // hmm thats backwards.. for(j = 1; j < patternSize; j++) { //This is risky as max_value is huge //test backwards into the recent cache to get the correct one. //This has the benefit of working sooner. Point2D.Double test = (Point2D.Double)patternLog.get(i-j); Point2D.Double recent = (Point2D.Double)patternLog.get(j); Point2D.Double test1 = (Point2D.Double)patternLog.get(i-1); Point2D.Double recent1 = (Point2D.Double)patternLog.get(j-1); test = new Point2D.Double( Utils.normalRelativeAngle(test.x + test1.x), test.y); recent = new Point2D.Double( Utils.normalRelativeAngle(recent.x + recent1.x), test.y); //Now i'm not 100% sure exactly how this works, but lets hope it works well enough. //Otherwise it will have to be changed. testScore += test.distance(recent); } //Need to find a way to turn this into a angle now //I hope this works Point2D.Double newPos = (Point2D.Double)patternLog.get(i+1); newPos = project(locationOfEnemy, Utils.normalRelativeAngle(current.x + newPos.x), newPos.y); testAngle = absoluteBearing(myLocation, newPos) - absoluteBearingToEnemy; if(testScore < bestScore) { bestScore = testScore; bestAngle = testAngle; } } angle = bestAngle; }//End (patternLog.size() > patternSize) if statement setTurnGunRightRadians(Utils.normalRelativeAngle(absoluteBearingToEnemy-getGunHeadingRadians()+angle)); setFire(3);
I just don't know what its doing wrong, it should aim and fire where the bot should be next. -- Ann
Do some graphical debugging - draw where your robot thinks the enemy is and where they should be. At least, assuming it's merely inaccurate, rather then actually crashing. I wrote a simple pattern matching gun recently, and that had the problem that I had the sign one of the factors the wrong way around - so I was working out the right pattern, it was just the wrong way around. You might have a bug like that.
Your Java code is much better then mine, though. It's Greek to me. --Jp
I have no idea how to do visual debugging. I decided to scrap the code, it was making robocode run really slow. I'll try making one with normal arrays and reweight the heading which has a weight of about 6 (0 to 2pi) and the velocity which has a weight of about 14 (-8 to 8). Perhaps set the velocity to absolute. --Ann