Author Topic: New rammer AI  (Read 1377 times)

Offline Clickbeetle

  • *
  • Posts: 3374
  • Rep: 21
  • In Soviet Russia, bugs stomp YOU!
  • Awards BOTM Winner
    • View Profile
    • Beetle Bros site
    • Awards
New rammer AI
« on: January 12, 2010, 06:05:13 PM »
https://gametechmods.com/uploads/files/RammerAIv3.zip

(Includes Tactics.py and SwitchDirRam.py)


What it does: if the bot is within a certain range (default 5 meters) of the opponent and is moving slower than a certain threshold speed (default 3), the AI attempts to drive away for another ram.  If the bot is facing the opponent, it backs up; if it is facing away from the opponent, it drives forward; and if the opponent is on its flank, it turns to face the opponent and then backs up.  If it can't get away (there is an obstacle in its path) it will face the opponent and push back.  While the AI is driving away, it is constantly checking for clear paths in front of and behind it.  It will continue to drive away from the opponent until it either detects an obstacle in its path or it is a certain distance away from the opponent.  At that point it will charge the opponent again.

How it's different from the previous rammer AI:
-Better hazard avoidance.  The obstacle c all but ensure the AI won't run into walls or hazards while backing up.
-The AI will usually run away first and then turn to face the opponent for a ram.  The only case in which it tries to turn first is if the enemy is exactly to the side.
-The point at which the AI will stop backing up and charge the opponent is based on distance/presence of obstacles rather than a timer.  The result is usually greater distances over which a ram is performed.  Most bots will back up the length of the Combat Arena, stop just before hitting the wall, and then do a boxlong charge.


The new Tactics.py replaces the old Ram and Charge tactics.  Both use the same code, but have different default values for some variables.  As before, Ram works better for fast bots and Charge works better for slow bots (although both can be customized to fit any bot type).

And thanks to Trovaner's help, I've also managed to include several customizable settings you can put in Bindings.py:

'ThresholdSpeed' is the speed below which the AI will stop pushing the opponent and back up for another ram.  The Ram default is 3 and the Charge default is 0.5.

'SightRange' is the base distance the AI "sees" in front of it for obstacle checking, distance from the opponent etc.  The base SightRange is automatically increased with the bot's speed for obstacle checking.  The base SightRange is also how close the AI needs to be to the opponent before it will back up for another ram.  And finally, the AI will continue backing up to a distance of twice its base SightRange, at which point it will charge the opponent.  The Ram default is 5 (so the AI will back up 10 meters for each ram, and will start backing up if it is less than 5 meters away from the opponent and moving slower than its ThresholdSpeed) and the Charge default is 3.

'BackUpTime' is a totally optional feature.  If you set a value for it, then the AI will only back up for a certain amount of time.  This is for bots that don't drive straight in reverse.  So if your bot spins out after 1 second of reverse, you can set a BackUpTime of 1 second to prevent that from happening.  BackUpTime is measured in ticks.  To convert ticks to seconds, divide by four (so 4 ticks = 1 second).  For reference, the timer on the old Rammer AI was on a 5-tick cycle.  So setting 'BackUpTime':5 will basically recreate the old Rammer AI only with better obstacle avoidance.

Here's some example Bindings for the new Rammer AI:

Code: [Select]
    list.append(("Generic Rammer","Rammer",{'nose':math.pi,'invertible':True,'radius':1,'topspeed':100,'throttle':100,'turn':60,'turnspeed':1,'SightRange':4,'ThresholdSpeed':2,'BackUpTime':5}))


I've also included an improved ReverseRam tactic that actually works, and a slightly modified SwitchDirRam.py to go with it.

IMPORTANT NOTE

The obstacle detection code ONLY works if the walls and obstacles in the arena are delineated with CollisionLines in the arena .py.  The AI will fail to detect obstacles in arenas without CollisionLines.

All the stock arenas, most if not all of the DSL arenas, and all of my custom arenas have CollisionLines.  However the Small Arena lacks collision lines; therefore
I have uploaded a new version with an updated .py that will work with the new Rammer AI.

Whew, long post.  Hopefully it will make the new AI easy to use though.  Happy AI'ing!

To lack feeling is to be dead, but to act on every feeling is to be a child.
-Brandon Sanderson, The Way of Kings

Offline Scrap Daddy

Re: New rammer AI
« Reply #1 on: January 12, 2010, 06:10:43 PM »
Sounds great, Click. Thanks

Offline JoeBlo

Re: New rammer AI
« Reply #2 on: January 12, 2010, 09:08:19 PM »
AWESOME  :mrgreen:

yoy say ReverseRam tactic? does this mean the robot will back up if the opponent is around the back of it ?

becasue me and 123 have been putting our heads together trying to AI his CC3 entry to avoid trying to turn around once the opponent goes underneath

would this serve that purpose ?

Offline Clickbeetle

  • *
  • Posts: 3374
  • Rep: 21
  • In Soviet Russia, bugs stomp YOU!
  • Awards BOTM Winner
    • View Profile
    • Beetle Bros site
    • Awards
Re: New rammer AI
« Reply #3 on: January 12, 2010, 09:13:09 PM »
ReverseRam is just a tactic that essentially reverses the bot's nose, so the front becomes the back and vice versa.


I used it to AI Juggernaut Mk.3 in BBEANS5, but it didn't work very well.  It's fixed now.


I don't think it will work for Flying Guillotine though.  All SwitchDirRam does is change tactics from Ram to ReverseRam when the bot's primary weapons break.  To do what you're thinking, you would need to be constantly switching back and forth between Ram and ReverseRam depending on where the opponent is.  Which might be possible, but I haven't tried it.

To lack feeling is to be dead, but to act on every feeling is to be a child.
-Brandon Sanderson, The Way of Kings

Offline JoeBlo

Re: New rammer AI
« Reply #4 on: January 12, 2010, 09:17:28 PM »
I see.. damn :P

I raided all the BBEANS AI py's trying to mod them to work

I guess it needs to be like the Left,Right Whipper but Forward and Back

Offline Madiaba

Re: New rammer AI
« Reply #5 on: January 12, 2010, 10:21:22 PM »
Nice, CB. I'll check it out.
Having not looked thorugh and tested it yet, it looks pretty comprehensive in handling itself.... The only thing I can suggest is maybe adding an 'Evade' mode for loss of all weapons (and if you're winning).
Input is appreciated. :)
-Arrogance is a quantity devoid of quality...
-As a client once told me "This is my story, and it's sticking to me!"
-Relationships these days are like the 'Arrival' section of the airport: a lot of baggage is being revealed in one place, and not a lot of it is being correlated to its real owners...