From the Old Wiki
NOTE: Anti-Grav movement is not really that original, in the field of robotics this is called potential field movement. Although the implementation mentioned here is an interesting take on the idea. (Added 4/20/05) Troutinator
Moving around, avoiding being hit (DodgingBullets) or rammed by enemy robots as well as WallAvoidance can be quite trickier than you'd think at first. Someone suggested using the laws of gravity for this, but reversed. Something along these lines:
- Assign anti gravity objects of varying charge to enemies, enemy bullets (possibly VirtualBullets), walls, whatever.
- Make your bot repell from those objects based on their charge.
AntiGravityMovement makes for a great Melee strategy as it tends to keep your bot away from the center of the field and from large groups of other bots (who tend to annihilate each other quickly.) Standard practice is to use the inverse square of the distance from the target you wish to repel, take that force as a vector and break it into X and Y components, then add up all the forces you currently are tracking and use this to tell your bot which direction to move. DustBunny uses a very simple AntiGravityMovement routine and is a NanoBots class robot so it should be very easy to understand. For more advanced version, people put artificial antigravity points along the walls and usually 1 in the center of the field. This gives you wall avoidance and center of the field avoidance. Fermat, TheArtOfWar, and many of the best bots use this as their primary mode of movement as it tends to be hard for pattern matching aim to get a lock on this movement. There are other tutorials, but I can't remember where they live at the moment.
The original anti-gravity code can be found in Relativity, version 3_7 still exists on the RobocodeRepository.
The idea was indeed to use the formula for gravity , mass/distance-squared, and then move away from the attraction. I have also experimented with using the square-root of the distance (reason: if a bot is 600 or 700 or 800 away, I think I care about them equally, and the square-root is less codesize in a MiniBot). So far, I think the original formula is most robust.
I'm using a variation on AntiGravityMovement for my new 1v1 bot, and it seems to be working pretty well. I'm a newbie to high level Robocoding (took at stab at it 3 years back, but I've grown a lot as a coder since then), so I am open to comments/suggestions about all this. Basically, I have two other types of ForcePoints: WindPoints and SwivelPoints; more could easily be added in the future, and probably will be. The WindPoint only emits a force in a particular direction, no matter what your bearing to it is. The SwivelPoint emits a force perpendicular to your bearing to it; it randomly chooses which way, unless you're near a wall, in which case it chooses the angle closest to the bearing to center (basic wall avoidance).
The idea first arose because I was quite displeased with how GravityPoints functioned as wall avoidance. WindPoints from the corners and wall midpoints work much better for me. The SwivelPoint was created to add a tendency of being perpendicular to the opponent, but I have since begun using them for WaveSurfing, as well. Lastly, I allow each point to have a custom "distance factor" in the equation 1/distance^DF, which adds some additional flexibility. If you make the distance factor == zero, then the strength is the same at any distance; for WaveSurfing, I do that and make the strength 1/distance-to-wave-edge.
In the future, I may make PulsePoints (force pulsates with time) or RandomPoints (random force). I find this type of force sum system very easy to work with, and I haven't really found anything I couldn't do with it yet - bullet dodging, random movement, and wall avoidance I've done, and I'm working on WaveSurfing now.
I took a shot at wavesurfing with antigrav a while back but I never got it to work quite right. Despite all of my efforts, my bots always seemed to want to move directly away from bullets (certain death) rather than move perpendicular to them. I always thought that the idea had merit but could not get it to show. I'll be interested to see if you get it to work correctly Voidious. --wcsv
I tried something like that too. I had gravity lines, and gravity valleys. I used the lines for wall avoidance and the valleys to get a certain distance to the enemy. But it was not as good as my simple perpendicular movement with wall avoidance... --Krabb
I know how anti-gravity is suppose to work in theory, I just can't figure out how to impliment it in a robot. -- Chase-san
@Chase-san: maybe you could use anti-gravity with some other movement, like maybe put some anti-gravity force on other bots and walls, and a gravity force on where the movement tells you to go. An example of how anti-gravity is used is here. --Starrynte
I've worked really hard on a bot that simulates bullets and I've finished that part, and now I need to use Anti-Gravity movement with it. But I don't know how to do it! I've never done any complex movement before... --Awesomeness 00:33, 4 May 2009 (UTC)
This is where I started, several years ago: Secrets from the Robocode masters: Anti-gravity movement --Darkcanuck 01:20, 4 May 2009 (UTC)
- I don't get it, it's so complicated... Ugh. --Awesomeness 01:54, 4 May 2009 (UTC)
- Well, it's not that I don't know how it works, I just don't know how to change it so that the bullets are antigrav points. I understand it, but I don't know how to implemnent it.
- Using Google's cache feature, which saves pages, (The old robowiki just gives 404s now.) I've been able to look at Hanji's antigrav engine, and it's very clear. I think I'll even be able to make my own off this. --Awesomeness 15:04, 4 May 2009 (UTC)
- I was once use Hanji's antigrav engine. I cannot make it working so I start working on DustBunny prototype instead. But I don't blame it, just my experience, and I admit that it is very neat engine. And if you think you will visit the old wiki frequently, you may want to use your host file to point to the old wiki which I, Voidious and probably some more used. (see Talk:Migration, I can't remember which section is it in.) » Nat | Talk » 15:18, 4 May 2009 (UTC)
- Just a note, in case you haven't already done this: Treating bullets as straight-up anti-grav points may result in your robot trying to run directly away from bullets, which is a good way to get killed. You should make your anti-gravity force vector point in a direction that is perpendicular to the line between the bullet and the bot that fired it, so that your bot will flee *sideways* from the bullet. RobertWalker 15:44, 4 May 2009 (UTC)
- Ugh... *Rips hair out* I can't do it... I wish there was an Anti-Gravity Tutorial... I can't understand the IBM tutorials and I feel like DustBunny's is in some ancient language... =( It's so hard for me to learn all of this stuff... And for you guys it always just slips off your fingers like it's 2+2 or something... I'm so jealous. <Insert jealous smiley here> Awesomeness 22:43, 19 January 2010 (UTC)
- Hey, it's nice to see you back on the wiki! Elite 1.0 has been one of my anti-linear targeting test bots since you created it, and I'd love to see some more stuff from you. Anyway, on a note that relates to this page...... I think having an Anti-Gravity tutorial is an excellent idea. Anti-Gravity can be a competitive movement, but is often hard to understand for beginners and people who haven't learned the math yet (I seem to remember having a ton of trouble with it). Since I have some free time today and this week, I might take a stab at making one if noone has any objections... Thoughts?--CrazyBassoonist 01:04, 20 January 2010 (UTC)
- Please feel free! I'm sure most of us would have no problem offering suggestions or corrections - it's writing from scratch that's the hard part. =) For some of the trig stuff, you might try to find some good trig/math stuff to link to instead of (or in addition to) writing that stuff yourself. And Awesomeness, if you have specific questions about the IBM tutorial/code, please feel free to ask. There may be some little things that are throwing you way off. --Voidious 15:17, 20 January 2010 (UTC)
- Would a tutorial on Virtual Bullets be useful at all? I could make one; I've already made a robot solely for the purpose of simulating where he'd fire if he had <insert targeting system name here> targeting. I don't think they're used that much anymore, but maybe... Just maybe I'll make one on my BulletSimBot, which tracks where the targeted enemy would fire if it used Linear Targeting. Awesomeness 00:52, 21 January 2010 (UTC)
Thanks. I didn't feel it was appropriate to use here, since it wasn't a full article about it in wikipedia, in fact it's barely even worthy of calling a paragraph. --Rednaxela 17:56, 11 August 2009 (UTC)