Difference between revisions of "Talk:Anti-Gravity Movement"
(New page: == 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 ...)
|Line 1:||Line 1:|
== From the Old Wiki ==
== From the Old Wiki ==
Revision as of 01:33, 4 May 2009
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)
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