# CelticSwarm

Robo Home | Changes | Preferences | AllPages

To infinity and beyond! Well I will certainly try...

I saw recently on the halowiki and saw that PEZ was spending a bunch of his time Robocoding again. Sometime later when I had some spare time I thought to myself, I havn't done any robocoding recently. So I looked at this and started to read up on some stuff since I havn't really done much of anything complex in robocoding. (basic targetting systems linear and orbital targeting) Most of this stuff seems quite complex. One question I do have is it possible to find out the position and velocity of a bullet at any given tick, or do you have to scan it.(or not possible) Not exactly sure what you guys mean by virtual bullets or this wave surfing stuff. Although I do have an idea in my head, but I'm not exactly sure where the statistical analysis falls into the wave surfing.

What I was picturing when reading the wavesurfing thing is every bullet emits a wave and based on the strength of each wave you move in certain direction. Kinda reminds me of having a bunch of magnets each emitting a wave that repels you. And depending on the distance you are to the bullet (magnet) the more repulsion there is. Then kinda add up all the vectors and then you get the ideal direction you want to go. Hmmmmmmm which then you could have walls a certain value and the enemy tank a value as well. So how much wrong am I getting with this? --CelticSwarm

Hey, welcome!

One thing that is important to realize is that you can't "see" enemy bullets... You can only detect that the enemy has fired by noticing that their energy dropped from one tick to the next, and that it wasn't from hitting the wall or getting hit by a bullet. A "wave" is just a fancy word for "every possible spot a given bullet could be in"; the speed of a bullet depends on the amount of energy that went into it, which you can detect, so you can draw a circle in your mind of everywhere a bullet could be. VirtualBullets just means keeping track of all the information that would define a bullet that doesn't actually exist... This is usually to measure the "virtual" success of several different targeting systems (see VirtualGuns).

As for WaveSurfing, it's more like different parts of the wave have different strengths, as opposed to a whole wave has a strength. A WaveSurfer keeps tack of which parts of the EnemyWaves he's been hit the most on, and avoids those parts of the future waves. Anyway, that should answer some of your questions... There's a ton of great info on this wiki, too, so dig around :) And a lot of bots are OpenSource (including PEZ's excellent CassiusClay), so you can learn more details from reading source code if you feel comfortable doing that. Good luck! -- Voidious

Oh, by the way, what you were describing is pretty much AntiGravityMovement, which is used a lot in melee. -- Voidious

To expand on the Virtual Bullet concept: Your tank is limited to firing one bullet every 16 or so ticks (determined by bullet power and gun cooling rate) but that doesn't mean you can't pretend to fire and see how often you would have hit. The trouble is that your success rate with virtual bullets tends to be greater than with real bullets, since many bots (i.e. the good ones) change their heading and / or speed when you fire at them (which they deduce by an otherwise unexplained drop in power). Still, a significant portion of your rating is based on how completely you dominate the lesser robots, and virtual bullets can give you an edge in determining where to shoot in order to hit your target earlier, giving them less time to drain their power returning fire (which means better score ratio). You may even determine which gun to use before you take your first shot, since your opponent may be moving right off the bat. -- Martin

(Edit conflict, I paste my contribution as if I were the first one to answer.) Welcome dude. You're both wrong and right with your interpretation of WaveSurfing. What you're describing is more like traditional AntiGravityMovement, something that I think is more useful in Melee. Wave surfing is yet a OneOnOne technique. Let's start wiith the Wave. Many bots, definately most of mine, use waves for their StatisticalTargeting. Think of the wave as the rings extending from a stone you drop in water. I fire a wave every tick. These particular waves travel at the same speed as a bullet. The wave object contains my position and the bearing to the enemy at the time the wave was fired. When the wave "hits" the enemy I check the bearing change of the enemy (measured from the wave origin). This bearing change is then used to update my statistic buffers. When I fire real bullets I fire at the most common bearing changes. Now, WaveSurfing is the opposite. You send out waves from your enemy and check your own bearing changes instead. The complicated part is predicting your own possible positions when the wave hits you. I predict three position in my orbit around the enemy:

1. where I would end up if I continued full forward
2. if I reversed orbit direction and
3. if I stop
I check the stat buffers about what stats each of these bearing changes has and go for the option with the least historical hits. When the wave actually hits I look for the next wave carrying a bullet. When I am hit by bullet I check what wave is most likely to have been carrying the bullet and update my stat buffers. Against simple targeting, like HeadOnTargeting it takes only one hit for my bot to learn and then that bot shouldn't hit me again. Run CassiusClay against a bot like HawkOnFire and you'll see it in action.

(Instead of bearing changes I actually use GuessFactors (where GF 1 is continuing full forward in the orbiting direction and GF -1 is maximum reverse and GF 0 is where HeadOnTargeting hits.)

Check out CassiusClay/Butterfly for a more in depth description of my style of WaveSurfing. Check out RandomMovementBot for an example of simple orbiting movement. That orbit movement is at the core of CassiusClay's surfing.

Detecting bullets. The only way is to keep track of the enemy bot's energy level and when it drops with something between 0.1 and 3.0 you are quite certain it fired a bullet. Because when it is hit by your bullets the energy level most often drops more than 3. See DetectingFire.

-- PEZ

So if someone has this guessfactor targeting system could you do something like keep a guess factor on your self like simulate the waves from a enemy like initiate them at the enemys position(I think you can find enemy pos). Then keep stats on your self on where the best choice to hit yourself would be and then not be there. --CelticSwarm

That's WaveSurfing in a nutshell. It doesn't matter what targeting system the opponent has though. -- PEZ

Well, actually, WaveSurfing keeps track of where you *have* been hit and avoids those spots... Although some of us do give a little weight to where we should be hit, too, like you are suggesting. Dodging where the enemy would fire at you with GuessFactorTargeting is a bit risky, since you are really overestimating the targeting skills of most opponents. Also, unless you have the exact same Segmentation data, it won't line line up enough to make that worth while. Tracking where you have actually been hit tells you where the enemy thinks he should hit you, which is more valuable than where you think he should hit you =) -- Voidious

I have tried surfing my own gun's guesses only and it creates a powerful movement too. The point is that WaveSurfing is about creating those Wave's extending from the enemy position and then use that to collect stats on your own movement and then feed those stats to your movement. What stats you collect and what you do with those stats is left open. It's still WaveSurfing. -- PEZ

Oh ok I think I'm starting to get a hand on this stuff. And thank you guys for all the help clarifing things and such. I really appreciate it. --CelticSwarm

I think what I'm going to try making first is what you guys where calling Anti gravity type movement. Although I do prefer the name magnetic movement:). For the time being it will let me reaquaint myself with the different functions in robocode. This statistical stuff for the time being I'm gonna leave it alone till I get a much better understanding of it. Anyways I just want to see if the idea I have would work very well. Kinda what I discribed way up top thinking it was the wavesurfing, but with a bit of adaptation that I just thought of. --CelticSwarm

Well, I have never tried AntiGravityMovement myself. I have always regarded it way too complicated to my taste. I guess we all have different things we think of as complicated. =) -- PEZ

For all I know it is way more complicated codewise, but I can see what I want it to do and how it should move in my mind, whereas the statistical ones I really don't understand how its going to move as easily. I do have a couple of questions if anyones willing to answer. Can you figure out an enemy bullets velocity by the amount of energy lost? Is there any bots still in the competition that use linear firing methods? If so could you point it out I want to try something that would be funny if it worked with a linear firing bot, and I'm too lazy to try and figure it out right now. -- CelticSwarm

First, AntiGravityMovement is quite a bit simpler to get working than WaveSurfing, in my opinion, even if WaveSurfing is fairly simple conceptually. Bullet velocity is (20 - (3 * power)); power ranges from .1 to 3, so bullet velocity ranges from 11 to 19.7. There are definitely bots using LinearTargeting and even just HeadOnTargeting, probably NanoBots and MicroBots, in particular. There are (non-moving) bots that use HeadOnTargeting, LinearTargeting, and CircularTargeting in the WaveSurfingChallenge2K6, and their sources are all available in the .jar files (I think). Good luck! -- Voidious

Oh man! I just finished typing nearly that same thing. By the way, Welcome (back?) to the wiki CelticSwarm. --wcsv

If you guys want to know what I'm planning it's basically this a gun that is used as a defensive. Any of you ever heard of something like starwars missile defence system?(something along those lines). I think it would be hiliarious to make a bot that shot bullets out of the air. So basically gonna find when a bot fires, and attempt to shoot the bullets out of the air. -- CelticSwarm

I hope you don't find it discouraging that a lot of your ideas have already been tried =), but keep in mind that Robocode has been around a few years... BulletShielding ... It's definitely a cool topic that I'd also like to try sometime! -- Voidious

I guess I'm not really surprised that someone already did that. Main reason I wanted to do that was to have a bot stand still and do it. I was thinking that if you stood still it be easier to figure out where to shoot at to knock out bullets. Then most ppl all of thier bullets would be shooting at you all the time which may not be good. But I was thinking maybe if you where standing still and you had a guessfactor gun aiming at you the virtual bullet data would be saying to aim at you(gf 0?). But the actual bullets wouldn't be hitting you, possibly throwing off its data. -- CelticSwarm

WaveSurfing is quite like anti-grav actually. I think you could also use anti-grav techniques to avoid the dangerous parts of the waves. You see, the statistical part that you say you think is complicated would be needed also for good anti-grav movement. And it isn't complicated. All I do is chop the GF space up in an array and increment the bins accordingly. Surfing doesn't demand statistics any more than anti-grav does. Making a surfer that avoids specific, simple, targeting methods like head-on and linear is very possible and it wouldn't involve statistics. It wouldn't be as effective against the competition as statistics based surfing. Just as anti-grav without statistics isn't as effective as with it. Check out the CassiusClay/GL page. See that thick part of the wave? Think of it as the repelling end of a magnet and you'll see what I mean I think. And think of CassiusClay using anti-grav, but forcing itself to move along the rails going in orbit around the opponent. -- PEZ

BulletShielding isn't really working when you stand still. The lines representing the bullets are zero-width. And most statistical guns don't care if the bullets hit or not. It uses the waves (or VirtualBullets in some cases) instead and you can't shoot them down. =) -- PEZ

Have you ever thought of advancing your waves a few ticks ahead of where they normally are? I wonder if doing that will help get out of the way of things in an earlier time frame.(At least if your certain distance away advance them a few ticks). Seems like that may change up how the movement would work a bit. Maybe better surfing? -- CelticSwarm

The problem with that, Celtic, is that you get out of the way as if it came already, then can reverse back into it or go too far and hit it. (I could be wrong... back me up or disagree someone...) -- Greywhind

Well, in a way, some WaveSurfers already do that. Each tick, they calculate the exact number of ticks before the wave hits them (using precise simulation of Robocode Physics and their own movement code), find out how far in each orbit direction they could get before that time, and then find the safest spot along this "reachable" area of the EnemyWave and go there. PEZ has a really good description of his WaveSurfing algorithm on his Butterfly page (what he calls his movement). There's also good descriptions of the basic styles of WaveSurfing on the WaveSurfing page. My algorithm is very similar to PEZ's in my bot Dookious, which I describe on that page. -- Voidious

I just read some stuff on GuessFactor targeting. And to me with the general discription of it, it seems that theres a flaw in it. Discription was something like record data when you hit them and fire at the most hit factor. The problem that I was thinking with that, is that when you fire at an adaptive movement bot they will probably do something different. So say you fire, they see that you fired and move to a different spot. You miss, but the next shot you fire ends up hitting the bot. So the previous GF drops and the other one rises. So your more likely to use the one you hit with right? Well what if the only reason you hit with that one is because of your previous shot made them move to avoid and the next shot caught them in a bind. It seems to me that just recording stuff for hits and loses isn't enough for anti-adaptive movement bots. Would also need to record the sequence of GF that you fired. My thinking is that might work well, unless I'm missing something still on how things stuff gets recorded with wave surfing.

You find that a sequence hits, say a three shot sequence when they in a certain situation. Fire first two as .1 firepower then last one as a higher firepower. When the first two come it will see that it can make it safe from the shot, and most likely force it closer to the GF that you hit previously. -- CelticSwarm

WaveSurfing is intended to fool GF guns, and it happens to fool just about everything else too. The topic of anti-adaptive-movement targeting has been discussed quite a bit around here lately. As it stands right now, the top surfers are just really hard to hit using any targeting method represented in the rumble. The AntiSurferTargeting page has some good info on hitting adaptive movements though. --wcsv

Celtic, I don't see the part where the general description of GuessFactorTargeting talks about recording data when you hit the enemy. What you do is record data when the Waves hit the enemy. And, in my case, I fire Waves every tick, not just when I fire real bullets. This makes my targeting very fast in its learning and I use that to increase the level of detail in the segmentation of the data. The "flaw" you see might or might not be there. Keep in mind that WaveSurfing isn't the norm. About 25 bots out of 450 in the RoboRumble@Home uses it. And only the top 12 or so has something close to bug-free implementations. AntiSurferTargeting is a quite odd start for your Robocode career I think. =) Get really aquainted StatisticalTargeting first and that will help you understand the statistical part of WaveSurfing and from there AntiSurfer land is better entered I think. What I struggle with is making my AntiSurfer efforts impact only wave surfers. But so far it seems I pay some in lost performance against the rest of the bots (the other 425!). -- PEZ

PEZ gives good advice. But I did want to just comment that you are right that WaveSurfers do adapt quickly, and thus my best efforts at targeting them do involve quickly decaying the GuessFactor data the I record. However, the "certain situation" is not really a series of GFs you fired at, it's more like how far away the enemy was, their velocity, their heading, whether they were close to a wall, and such. Some decent info on the Segmentation page. -- Voidious

PEZ, I'm not so much tring to start my robocode career with these things so much as just kinda throw out ideas. I havn't done much codingwise on anything yet. I have to have a more solid idea of what I want to do otherwise it just ends up a wondering mess. I figure I just read bunches of things formulate ideas write them down if I have them, try to find flaws in them and what not. Then when I have a good plan make a bot. Well anyways heres another idea that would I think make a bot incredible against any non-adaptive movement bot.(although it might take a bit of cpu time, not sure).

So the white things are Virtualbullets. Now it seems that a wave is kinda like a lot of virtual bullets. Now the yellow circles are the waves that crazy is seeing.(not really nescary for my idea). The red wave is one that was emitted from crazy and has hit track. So you can find out the angles that are possible for hitting track.(red dot is center of circle, with angles). Now what you could do from there to get information much faster is to basically make the same size wave right then centered on track and anywhere from the edge of the circle you could find the angles of that would have hit track. (Blue dots with angles). Although most likely it would not work with ones that do things relative to your position, and could just end up throwing your stats way off, but against other bots would work like a charm I would think.

I don't think I quite understand the idea. You are right about a wave is like a lot of virtual bullets though. It's an infinite amount of virtual bullets. A virtual bullet would typically hold information about what GF it was fired in. And when it hits you immediately know what GF to reward. With a wave you figure the GF out when the wave has hit the enemy. -- PEZ

So the red wave is the one crazy fired. Now if the wave instead of being fired from where crazy was located on the time of fireing was fired from any position on the blue circle, would hit track at the same time. Which as long as the person didn't change there movement based on the position of the other player would get loads of information thats all good. But now that I think about it most bots probably have stuff that they change where they go based on the scanned robot event, which they know where the person is positioned. So most of those stats would kinda be invalid then unless there was some way to use them differently. -- CelticSwarm

I follow what you're saying with the red and blue waves, but I still don't quite see how it could help you target someone. (And yeah, I think most bots alter their movement based on your position and/or where you fire from.) The angle that helps you to target is the difference between "direct angle to enemy at fire time" and "angle that would have hit enemy at fire time", the latter being the line from the wave source to the spot where the wave hits the enemy. That difference is the angle offset that you "should have" fired at. While every angle along that blue circle would have hit them, I'm just not seeing how that information is useful... -- Voidious

Well if you pick a different spot on the blue circle as the spot your firing from, you'll get a different "direct angle to enemy at fire time" as well as a different "angle that would have hit enemy at fire time". So now wouldn't that get stored in a different bin? Now say that the person doesn't not change there movement based on your location, then this I think would work. Now if that would work against them what you could do is something like this... Take from keep a hold of waves, don't delete them right away. Only store the info into your guess factor gun of where you actually where, but one your next wave hits you can check some of the other angles to see if they lined up with the previous waves data. If it does that might mean that they are not moving according to your position.(might want to check this only on real fires to make sure they don't change move with bullet fires as well.) If you seems that they arn't moving with respect to your pos or your bullet fireing then you can start loading in the data from each wave, then the cowave(the blue wave in the pic). -- CelticSwarm

It still doesn't ring a bell here. =) But you could maybe test it against Walls and SpinBot. Their movement is totally independent on the opponents as long as they don't bump in to them. -- PEZ

Aye, so I could. Is there any way on to check effcientcy of targetting systems against specific types of bots? -- CelticSwarm

There's the TargetingChallenge and the TargetingChallenge2K6 and also the RRGunChallenge. But those might not be what you're looking for. Maybe we could make a new challenge for who's killing of the SampleBots in the most efficent way. If we all use CassiusClay/Butterfly movement then the sample bots won't hit us much and then it's about missing them as little as possible. -- PEZ

I was looking at Bee tring to figure out how I can go about doing this. I cannot however find where Gunwave class is defined. I see Wave though. Need to find where that is so I can take a look at the class to see what I the function calls and such are to get it to do what I want it to do. -- CelticSwarm

It should be in pgun/Bee?.java. -- Voidious

Heh guess I didn't look far enough down, assumed it was in a seperate file. whoops. -- CelticSwarm

I've been consumed with other things, and probably won't be on here for a little while. -- CelticSwarm

I was just thinking about good melee strategies, when i remembered CelticSwarm's idea of sending virtual waves from different spots, not only from your own bot position (If i undestand his idea right -.-). It would not be a good idea to do this in 1on1, because the enemy movement reacts on your position. But it could work in melee, the enemy bots react on your own position and on all the other enemies. So why not shooting virtual waves from all remaining enemy positions? The learning rate of this gun would be much higher then a normal one, i think more then three times! A problem is that you have not that much information about all the enemy bots, but I´m sure it is a improvement.

EDIT: It may not work against every bot, because some bots react on the enemy guns, but i think many meele movements just react on distance, energy and orientation. --Krabb

Robo Home | Changes | Preferences | AllPages