Squirrel

From Robowiki
Jump to navigation Jump to search

/Nano

Bot Name

Squirrel

Author

Bayen

Extends

AdvancedRobot

What's special about it?

My first megabot. My first semi-good robot. (it's my only one ever to be in the top 100 of the roborumble)

Great, I want to try it. Where can I download it?

http://www.freewebs.com/bayen/files/bayen.nut.Squirrel_1.59.jar

How competitive is it?

Mediumly.....

How does it move?

It starts out by trying to circle the enemy (to avoid HOT), if that fails, it "buzzes" back and forth (to avoid LT or CT), and if that fails, it waveSurfs (by avoiding the GF that it was hit at last AT ALL COSTS while having the secondary motive to try and keep a flat movement. this should help against bots without adaptive guns).

How does it fire?

VirtualGuns array! With one main GF gun, one anti-adaptive GF gun, and one LT gun

How does it dodge bullets?

see Movement

How does the melee strategy differ from one-on-one strategy?

it moves from corner to corner using goTo() code instead of circling the enemy. This creates a Walls-like movement, except without the collision damage. It will change its destination if it is hit by another bot.

How does it select a target to attack/avoid in melee?

basically, whoever it sees.

= What does it save between rounds and matches?

Between Rounds: VirtualGuns array information, GF info, WaveSurfing info, its gun accuracy, its dodging effectiveness, and what movement pattern it is currently using.

Between Matches: main GF gun data

Where did you get the name?

From the ultimate species: the squirrels.

Can I use your code?

Sure! It's in the JAR and I haven't liscensed it or anything (I may do this later, but for now it isn't worth it ;) )

What's next for your robot?

I don't know yet.

Does it have any WhiteWhales?

BasicGFSurfer!!!!! (the combination of the WaveSurfing tutorial bot and the GF tutorial bot...)

What other robot(s) is it based on?

I use modified versions of code from VirtualBulletsSampleBot, BasicSurfer, and GFTargetingBot. So that means thanks to PEZ, DavidAlves, and Voidious! I also used the WritingArraysToFile code and the WaveSurfingChallengeBotB code.


Comments, questions, feedback:

Help!!!! My code will compile, but this error occurs whenever I battle:

bayen.Squirrel: Exception: java.lang.NullPointerException
java.lang.NullPointerException
    at bayen.AcornSlingshot.onScannedRobot(AcornSlingshot.java:19)
    at bayen.Squirrel.onScannedRobot(Squirrel.java:76)
    at robocode.peer.robot.EventManager.onScannedRobot(Unknown Source)
    at robocode.peer.robot.EventManager.processEvents(Unknown Source)
    at robocode.peer.RobotPeer.tick(Unknown Source)
    at robocode.peer.RobotPeer.turnRadar(Unknown Source)
    at robocode.Robot.turnRadarRight(Unknown Source)
    at bayen.Squirrel.run(Squirrel.java:69)
    at robocode.peer.RobotPeer.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

WHY?!?!?!?! Please someone look at my code and tell me. --Bayen

Bug fixed :) --Bayen

Can someone help me implement a VirtualGun array for this bot? I want to use a CT gun and a HOT gun. I'm not sure how to begin... -Bayen

Check out VirtualBullets/VirtualBulletsSampleBot for a sample of virtual guns. I've also added screenshot of the bot in action at the top of the VirtualBullets page. --David Alves

Thanks! I'll get right to work :) --Bayen

And I tried, and I failed.... Could someone help with debugging this implementation? It's basically VirtualBulletsSampleBot reconfigured onto Squirrel. The gun source can be found at http://robowiki.net/cgi-bin/robowiki?Squirrel/Gun . The code WILL compile, but for some reason it gets an error:

bayen.Squirrel: Exception: java.lang.NullPointerException
java.lang.NullPointerException
    at bayen.AcornSlingshot.onScannedRobot(AcornSlingshot.java:50)
    at bayen.Squirrel.onScannedRobot(Squirrel.java:87)
    at robocode.peer.robot.EventManager.onScannedRobot(Unknown Source)
    at robocode.peer.robot.EventManager.processEvents(Unknown Source)
    at robocode.peer.RobotPeer.tick(Unknown Source)
    at robocode.peer.RobotPeer.turnRadar(Unknown Source)
    at robocode.Robot.turnRadarRight(Unknown Source)
    at bayen.Squirrel.run(Squirrel.java:74)
    at robocode.peer.RobotPeer.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

I have a hunch that the error is somehow in this code because when I take it out, the error goes away. The downside is: I can't fire without this code:

target = new RobotState();
		target.setLocation(me.project(e.getBearingRadians() + Squirrel.getHeadingRadians(), e.getDistance()));
		target.heading = e.getHeadingRadians();
		target.velocity = e.getVelocity();
		target.name = e.getName();

However, the error message says that there are some problems with the bot code, too (which is at http://robowiki.net/cgi-bin/robowiki?Squirrel/Bot ), so I am checking that too. I am pretty much stumped. Could someone give me some help? --Bayen

I'd need to see the rest of the code to be able to know for sure, but my first thought is to make sure that 'me' is initialized before that code is executed. --wcsv

You're right! Thanks so much! Everyone here is so helpful, it's awesome. Thanks again! --Bayen

Hey Bayen, do you want to see a fight with hardly any hits? Pitch in Gruwel against Squirrel and watch all the bullets fly by. You will also see a minor issue for improvement: do not shoot yourself disabled. -- GrubbmGait

I did, it's funny! :) But which version of Squirrel do you have? I thought I put in something so that if it's not hitting 75% or more of the time it won't shoot once its energy drops to 5... --Bayen

The version I watched is bayen.Squirrel_1.25 (is corrected to bayen.nut.Squirrel_1.25). RR@Home was complaining about it, so I downloaded it and checked what was wrong. Then I also watched some battles against some of my own bots. -- GrubbmGait

I think I broke something in 1.50! I dropped almost 75 places in the RR@H. Maybe it's the flattening for my WaveSurfing... I must improve it! --Bayen

I'm stumped (with another error). Here it is:

bayen.nut.Squirrel: Exception: java.lang.NullPointerException java.lang.NullPointerException

   at bayen.nut.FleetFeet.onHitByBullet(FleetFeet.java:338)
   at bayen.nut.Squirrel.onHitByBullet(Squirrel.java:151)
   at robocode.peer.robot.EventManager.onHitByBullet(Unknown Source)
   at robocode.peer.robot.EventManager.processEvents(Unknown Source)
   at robocode.peer.RobotPeer.tick(Unknown Source)
   at robocode.peer.RobotPeer.turnRadar(Unknown Source)
   at robocode.Robot.turnRadarRight(Unknown Source)
   at bayen.nut.Squirrel.run(Squirrel.java:118)
   at robocode.peer.RobotPeer.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)

It doesn't happen every round, but it happens often enough to affect my score. It happens when I get hit by a bullet. (not EVERY time I get hit by a bullet, but it only happens if I have just been hit by the bullet.) I don't know why! --Bayen

What version of Squirrel? If it's a dev version, could you share some source code? I'd start on line 338 of FleetFeet.java, of course... ;) -- Voidious

Okay. This is what's at 338:

if(_myLocation.distance(hitWave.fireLocation) > 90 //if they're not too close
			&& (
			!(getFactorIndex(hitWave, hitBulletLocation) <= 20  //and not shooting HOT if we're anti-HOT moving
					&&getFactorIndex(hitWave, hitBulletLocation) >= 25
					&&waveSurf&&!flatten)
					
					|| (
					!(getFactorIndex(hitWave, hitBulletLocation) <= 42//and not shooting LT if we're antiLTing
					&&getFactorIndex(hitWave, hitBulletLocation) >= 47
					&&!waveSurf)
					)
					|| (waveSurf && flatten)//or we are waveSurfing
					)
					)
hitsThisRound++;                  //add a hit to this round

//then make neccessary changes:
		if(waveSurf && !flatten){
			if((hitsThisRound > Squirrel.getRoundNum())){
				hitsThisRound = 0;
				waveSurf = false;
			}
		}
		if(!waveSurf){
			if((hitsThisRound > Squirrel.getRoundNum())){
				hitsThisRound = 0;
				waveSurf = true;
				flatten = true;
			}

It's in onHitByBullet and it decides what movement I will be using. If waveSurf == true and flatten == false, it will do the anti-HOT movement. If waveSurf == false and flatten == false it will do the anti-LT/CT movement. If waveSurf == true and flatten == true it will do the waveSurfing movement.

I think this is where the error starts. If this isn't enough, I can create another release temporarily and upload it.

The error seems to be inside the giant if statement. I'm still working on pinpointing it. Help please?!?--Bayen

It's probably _myLocation. You could confirm that by adding something like: if (_myLocation == null) { System.out.println("Yes, it's _myLocation that's the source of my NPE."); }. If it were any of the other objects there, you would see getFactorIndex in the stack trace. I assume "Squirrel" is a reference to the AdvancedRobot itself? You should be updating that reference each round, too, if you aren't already... (By the way, which line exactly is 338?) -- Voidious

I added that line and it never printed, so I don't think it is _myLocation. Squirrel is a reference to the AdvancedRobot, and it does get updated every round (because I reconstruct my movement class every round). And 338 (which is actually now 339 since I added the debugger line) is if(_myLocation.distance(hitWave.fireLocation) > 90. --Bayen

Oh, then it's gotta be hitWave. If it were fireLocation, you would get the NullPointerException within Point2D.distance instead. (You'd have another line after onHitByBullet in your stack trace.) Where does hitWave get created? -- Voidious

It's hitWave. I added if(hitWave != null) {...} and the NPE disappeared. Thanks! --Bayen

Okay, I've been working at Squirrel for a while today with negligible results. So I released 1.55 just for fun. Could someone take a look at it and just give me suggestions if you have time? --Bayen

Are you sure that your GF gun is working properly? Until you're 100% sure, I wouldn't bother with movement. Also, I would disable VirtualGuns while you're working on your GF gun. I'd also use the debugging graphics to draw stuff onto the screen so you can visually check if you have any errors. For example, you could draw waves, draw an indicator where GF1 is, etc. Good luck! --David Alves

Ironically, the GF gun is fine, but the VG array is awry. I accidentally messed something up while modifying it and made it select the wrong gun. Now it should be better in 1.57. Also, I think my WaveSurfing has improved since the last release. At least, that's what it seemed like when I was testing. You never know how it will do in the rumble. I'm just going to wait and see :) --Bayen

YAY! 1.57 finally got into the top 100 of the Roborumble! That's my first time :D. I don't know how well 1.58 will do, though. I just put it in. All I changed was some segmentations of the main GF gun, but who knows what that will affect. Anyway, I'm sort of stuck on what to do next. Any ideas? --Bayen

Congratulations! It could be good to test Squirrel in the MovementChallenge2K6 and TargetingChallenge2K6 to see if it has any deficit. I would test every gun separately in the challenge and use only the best two or three Guns, one vs bad moving bots and one or two vs good ones. --Krabb

You will get your bot processed a whole lot faster if you do not use the new interface options. (I do not know if there are more interface changes than the setColors method.) Some people, including David Alves and myself, run the Rumble with 1.0.7, and any bots that try to use the new interface will fail and get a score of 0, which doesn't hurt their rating but it means they are just wasting time and not getting the benefit of battles run by those people (which is a lot). I am not trying to say you can't use the latest version, but it is beneficial to you to avoid it. -- Martin

I'm using 1.1.3 for RRAH now, because sometimes 1.0.6 was producing nonzero scores for bots even if they immediately crashed due to setColors. --David Alves

Okay, in the next release I will use the old setColors --Bayen

Wow, adding data saving between matches bumped Squirrel up over 50 places in the rumble! I didn't know what I was missing! (and some help from extremely cutting down on the VG array) --Bayen

I dunno, I kinda doubt that you could attribute so much of the jump to the stats saving. It depends on the gun, of course, but I think it's probably only worth 5-10 points, in general. (Unless you pre-loaded it with data on everyone...) Always nice to see such a huge improvement, in any case ;) -- Voidious