/Help -
/CodeSnippets - Discussions
/AsOf20060129
VirtualGuns is a way to choose the best aiming method against a given enemy by keeping track of each methods' virtual hit rate (or some other measure). There are obvious advantages:
What are the advantages
- Enemies tend to move quite differently, VirtualGuns will make your robot adapt.
- In theory it's can be quite easy to implement.
- You can let your bot explore quite different Targeting techniques, even quite simple ones, in the hope that it will find weaknesses against particular opponents.
- For example against some bots HeadOnTargeting is better than many other targeting implementations. (Against a truly flat movement it can be better to just guess head-on all the time than risking to guess differently and wrong too many times.)
Disadvantages
- The main disadvantage is that in practice it can be quite hard to implement.
- You risk messing up things so that the array performs worse than your best gun would do on its own.
How does it work?
Marshmallow was my first bot using
VirtualGuns (ehh, it was my first bot, period). It uses the following strategy for this:
- Everytime the robot is ready to shoot it creates an array of virtual guns and aims each of them
- When firing it stores this virtual gun array in an event
- The event's test() method checks wether a particular virtual gun has either hit or missed (using Waves).
- Statistics are updated for each gun which has either hit or missed
- When all guns are finished the event is deregistrered and the virtual gun array is disposed.
Note that there's no event handler for this event. I only use it to store the copy of the virtual guns array and to get Robocode to run the test each tick. Like
VirtualBullets/VirtualBulletsBot does.
--
PEZ
What bots are using this?
Please add relevant bots to this list.
- SandboxDT
- Duelist also uses "virtual guns", it used them to decide how fast it should adapt its aim, ranging from "fire using whichever virtual bullet hit last time" to "fire using the virtual bullet that has been most effective on average over all data vs. this bot". --David Alves
- Mako, MakoHT
- OrcaM
- GB
- SpareParts has a bunch of them, which help him proof himself against brutally simple robots (I made robots later that did much better against good robots and ranked higher, but couldn't beat Walls).
- Ascendant
- CassiusClay (as of this writing in a development version)
- Dookious presently uses two GuessFactor guns in a VG array. One has a higher depth on the RollingAverages and uses non-firing waves, the other uses only "real" waves and has a much lower rolling depth (aimed at WaveSurfers / adaptive movements).
- All of Greywhind's bots use VGuns so far - all simple targetings, Laser, GF, and PM are included in Constitution and Strength.
- GrubbmGrb has a VG array of simple targeters (HOT, CT, random, av velocity CT and orbital)
- Ugluk has been using multiple simple targeters since before 0.3.0 (first Roborumble entry). I wanted to be able to defeat all sample bots before I entered, and what works for Walls does not work for SpinBot. Ugluk varies as to how many guns he has, but it has been as high as eleven at once.
- Perpy uses four different guns, using virtual bullets to assess hitrate. Respectively, they are HOT, CT, a GF gun and a patternmatcher.
- Squirrel uses a pretty big virtual guns array, including 4 GF guns, 3 AntiSurfer GF guns, 1 CT gun, 1 LT gun, and 1 HOT gun.
One detail that I think makes sense is this: weight your VirtualGuns data (hits and misses) proportional to the difficulty of hitting the enemy in that situation. For instance, 12.5% vs 12% at distance of 500 is the same ratio as 25% vs 24% at a distance of 250, but if you have an even number of data from each distance, the latter has more effect on that calculation, while it should be the same. So far, I've been weighting my VirtualGuns data proportional to distance, but I'll be making it bullet time (slightly more accurate) and total reachable escape angle (which I already calculate precisely in Dookious). -- Voidious
Sounds reasonable. Would it also be helpful to take into account the percent of maximum escape angle taken up by the bot at each distance? -- Simonton
The above two factors are actually my attempt to calculate exactly what you said - the average hit rate for RandomTargeting in that situation = exactly proportional to bot width / total escape angle. That percentage is proportional to both bullet time and the total escape angle. Can you think of any other factors? I would definitely add them if I knew them, but I think those two paint the whole picture. -- Voidious
If your escape angle calculation takes into account wallsmoothing, then I can't think of anything else. -- GrubbmGait
- Yep, Dookious uses precise escape angles that take walls into account. -- Voidious
- Hmm, hey wait. Distance is a factor in both bullet time and total escape angle, so I may be counting that one more than I should. Maybe it should be just distance and total escape angle? I decided on bullet time instead of distance before adding in the total escape angle thing... -- Voidious
- Yes, you are right. You're not going to get it exact, because to convert bot width to an angle requires knowing the angle at which the bullet would hit the bot (because the bot is a square) as well as the distance to the bot (which can vary depending on whether the bot advances or retreats, e.g. for wall smoothing), but you already knew that. Anyway (bot-width-angle / escape-angle) or (bot-width / escape-distance) do encompass the whole picture, they're just slippery variables to nail down. -- Simonton
Has anyone tried VirtualGuns within VirtualGuns? I think this could be effective against surfers, because your anti-surfer VirtualGun? could choose between pattern-matching, a small DC gun, a lightly segmented GF gun, etc, and your regular gun could be just one, big GF gun. You can choose between your array of anti-surfer guns (which are treated as one gun by the 'main' virtual gun system) and your main gun using gun stats that have a very high rolling depth, but between the anti-surfer guns with a low depth. Because surfers constantly evolve their movement, at different points their movement might be more susceptible to different types of guns. -- Skilgannon
- I would imagine that a literal implementation of this would be ridiculously slow. However, an equivalent method would be to put all of the guns in a single array and modify the method used to choose between them to consider the anti-surfer guns as a collective group. Only if it picks the group would the choice function look at the individual anti-surfer guns. On the other hand, by itself it is probably really slow to have several pattern-matching guns and DC guns in a VG array, so it might not be practical either way. -- AaronR
- I understand what you're saying, but I have to ask - when would this ever be preferable to just choosing the best of all your guns? Do you really want to penalize choosing your best AntiSurfer gun by grouping it with your worst AntiSurfer gun in terms of VG rating? Also, I think it's really hard not to lose performance as you add more guns to a VG; often, it's best to cut the weaker guns even if they are better sometimes, because your chooser will never be perfect. -- Voidious