Author Topic: slamopponentfuriouslyintowall.py  (Read 1266 times)

Offline Reier

  • Rieir
  • *
  • Posts: 8579
  • Rep: 8
  • I GOT 3RD IN RAW1
    • https://www.youtube.com/c
  • Awards old BOTM Winner
    • View Profile
    • Awards
slamopponentfuriouslyintowall.py
« on: December 20, 2015, 10:12:59 PM »
seriously, is there a py that does something like this? I'm tired of my aied bots just doodlin around when they're gutripping the opponent, the thing needs to drive forward but it just sits still under the guy its killing when controlled by omni.py. I know eternalflame does something like this where it keeps going forwards upon contact but I need it to work with spinners and hammers and stuff. Anybody know?
ALERT- Another WS coming up...
voted best bot builder two times and counting babayy. the best ra2 builder who has never won an actual tournament match
ReiAI pack for Ironforge
My drawings, and my webcomics
Why online PVP will save RA2
The problem with competitive IRL in RA2
I'm fine with hugging reier

Offline Meganerdbomb

  • *
  • Posts: 3384
  • Rep: 6
  • Are you not entertained?
    • http://www.youtube.com/us
  • Awards BOTM Winner
    • View Profile
    • Awards
Re: slamopponentfuriouslyintowall.py
« Reply #1 on: December 20, 2015, 11:28:43 PM »
Sweet.  I love how detailed it is  (I'm starting to notice some pattern going on here).  Also, what exactly does "TopPusher.py" do that is used specifically for Apollyon?  Besides the hinge.

You know how when an AI bot is directly underneath another bot, it doesn't know what to do and just sits still?  TopPusher.py uses a smart zone on top of the bot to tell the AI to keep driving forward.  It results in more exciting pushing and wall slams, especially for bots with shallow wedges.
Ask Click I guess.
im just waiting for meganerdbomb to come along and kick things into gear.

Offline Merrick

  • *
  • Posts: 2530
  • Rep: 3
  • Half-decent IRL designs and terrible antweights.
  • Awards BOTM Winner
    • View Profile
    • Awards
Re: slamopponentfuriouslyintowall.py
« Reply #2 on: December 21, 2015, 02:49:24 AM »
Seems that it'll be available to all on the 26th when DSL 2.2 comes out then? :thumbup

Offline Naryar

  • Posts: 23283
  • Rep: 21
  • hybrids oui oui
    • http://www.youtube.com/us
  • Awards BOTM Winner
    • View Profile
    • Awards
  • Skype: TheMightyNaryar
Re: slamopponentfuriouslyintowall.py
« Reply #3 on: December 21, 2015, 03:50:03 AM »
yeah, ai not being manly enough is a problem

i think setting radius to zero (or to very low values) may solve that. but then again set radius to zero = so manly he doesn't give a sh** about traps and obstacles, soo...

Offline MassimoV

  • I Move Weight
  • *
  • Posts: 8929
  • Rep: 24
  • I make rap for people of Serbia
    • MassimoVTV
  • Awards BOTM Winner
    • View Profile
    • Mourning Glory
    • Awards
  • See profile for gamer tags: Yes
  • Skype: myhandsarefood
Re: slamopponentfuriouslyintowall.py
« Reply #4 on: December 22, 2015, 03:32:00 PM »
I'd say try TopPusher.py first. I have it in my Tournament AI pack.

Offline Reier

  • Rieir
  • *
  • Posts: 8579
  • Rep: 8
  • I GOT 3RD IN RAW1
    • https://www.youtube.com/c
  • Awards old BOTM Winner
    • View Profile
    • Awards
Re: slamopponentfuriouslyintowall.py
« Reply #5 on: December 22, 2015, 03:37:51 PM »
does it have support for omni-esque spinning weapons? I really don't know how to edit .pys if it doesnt
ALERT- Another WS coming up...
voted best bot builder two times and counting babayy. the best ra2 builder who has never won an actual tournament match
ReiAI pack for Ironforge
My drawings, and my webcomics
Why online PVP will save RA2
The problem with competitive IRL in RA2
I'm fine with hugging reier

Offline MassimoV

  • I Move Weight
  • *
  • Posts: 8929
  • Rep: 24
  • I make rap for people of Serbia
    • MassimoVTV
  • Awards BOTM Winner
    • View Profile
    • Mourning Glory
    • Awards
  • See profile for gamer tags: Yes
  • Skype: myhandsarefood
Re: slamopponentfuriouslyintowall.py
« Reply #6 on: December 22, 2015, 03:42:33 PM »
I don't remember honestly. I can't edit .pys either, Click made it so he's the master of it. No harm testing it out I guess.

Offline Clickbeetle

  • *
  • Posts: 3375
  • Rep: 21
  • In Soviet Russia, bugs stomp YOU!
  • Awards BOTM Winner
    • View Profile
    • Beetle Bros site
    • Awards
Re: slamopponentfuriouslyintowall.py
« Reply #7 on: December 24, 2015, 01:34:57 PM »
TopPusher does have support for spinners and burst weapons (though it only uses one smart zone, so the weapons and pushing zone need to share).

Just copy/paste this into a txt file and save it as TopPusher.py.

Code: [Select]
from __future__ import generators
import plus
import AI
from AI import vector3
import Arenas
import Gooey
import math
import Tactics

class TopPusher(AI.SuperAI):
    "Uses a smart zone to keep pushing bots even when they are on top of this bot."
    name = "TopPusher"
    # Needs a separate analog control named "Push" wired to the drive, and a smart zone named "Push".
    # Put 'tactic':"Ram" (or "Charge") in Bindings to make the AI use rammer/pusher tactics.

    def __init__(self, **args):
        AI.SuperAI.__init__(self, **args)
               
        self.zone = "Push"
        self.triggers = ["Fire"]
        self.trigger2 = ["Srimech"]
        self.reloadTime = 0
        self.reloadDelay = 3
        self.compinzone = 0
        self.spin_range = 3.0
       
        if 'range' in args:
            self.spin_range = args.get('range')
     
        if 'triggers' in args: self.triggers = args['triggers']
        if 'reload' in args: self.reloadDelay = args['reload']
       
        self.triggerIterator = iter(self.triggers)
 
        if 'tactic' in args:
            self.theTactic = args['tactic']
            if   self.theTactic  == "Charge" : self.tactics.append(Tactics.Charge(self))
            elif self.theTactic  == "Ram" : self.tactics.append(Tactics.Ram(self))
            elif self.theTactic  == "Shove" : self.tactics.append(Tactics.Shove(self))
            elif self.theTactic  == "Engage" : self.tactics.append(Tactics.Engage(self))
            else: self.tactics.append(Tactics.Engage(self))
        else: self.tactics.append(Tactics.Engage(self))
       
    def Activate(self, active):
        if active:
            if AI.SuperAI.debugging:
                self.debug = Gooey.Plain("watch", 0, 75, 100, 75)
                tbox = self.debug.addText("line0", 0, 0, 100, 15)
                tbox.setText("Throttle")
                tbox = self.debug.addText("line1", 0, 15, 100, 15)
                tbox.setText("Turning")
                tbox = self.debug.addText("line2", 0, 30, 100, 15)
                tbox.setText("")
                tbox = self.debug.addText("line3", 0, 45, 100, 15)
                tbox.setText("")
           
            self.RegisterSmartZone(self.zone, 1)
           
        return AI.SuperAI.Activate(self, active)

    def Tick(self):
        # Push when a bot is in the smart zone
        if self.compinzone == 1 and not self.bImmobile:
            self.Input("Push", 0, 100)
        else:
            self.Input("Push", 0, 0)
           
        # fire weapon
        if self.weapons:

            # spin up depending on enemy's range
            enemy, range = self.GetNearestEnemy()
           
            if enemy is not None and range < self.spin_range:
                self.Input("Spin", 0, 1)
            elif self.GetInputStatus("Spin", 0) != 0:
                self.Input("Spin", 0, 0)
           
            targets = [x for x in self.sensors.itervalues() if x.contacts > 0 \
                and not plus.isDefeated(x.robot)]
           
        return AI.SuperAI.Tick(self)

    def InvertHandler(self):
        # fire all weapons once per second (until we're upright!)
        while 1:
            for trigger in self.trigger2:
                self.Input(trigger, 0, 1)
           
            for i in range(0, 8):
                yield 0
               
    def LostComponent(self, id):
        # if we lose all our weapons, stop using the Engage tactic and switch to Shove
        if id in self.weapons: self.weapons.remove(id)
       
        if not self.weapons:
            tactic = [x for x in self.tactics if x.name == "Engage"]
            if len(tactic) > 0:
                self.tactics.remove(tactic[0])
               
                self.tactics.append(Tactics.Shove(self))
                self.tactics.append(Tactics.Charge(self))
           
        return AI.SuperAI.LostComponent(self, id)
               
    def DebugString(self, id, string):
        if self.debug:
            if id == 0: self.debug.get("line0").setText(string)
            elif id == 1: self.debug.get("line1").setText(string)
            elif id == 2: self.debug.get("line2").setText(string)
            elif id == 3: self.debug.get("line3").setText(string)
           
    def SmartZoneEvent(self, direction, id, robot, chassis):
        if id == 1:
            if robot > 0:
                if direction == 1:
                    self.compinzone = 1
                elif direction == -1:
                    self.compinzone = 0

        return True
   
AI.register(TopPusher)

This seems like a useful-enough feature that I might just add it to Omni.py for the DSL 2.2 release.

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 Reier

  • Rieir
  • *
  • Posts: 8579
  • Rep: 8
  • I GOT 3RD IN RAW1
    • https://www.youtube.com/c
  • Awards old BOTM Winner
    • View Profile
    • Awards
Re: slamopponentfuriouslyintowall.py
« Reply #8 on: December 24, 2015, 01:36:14 PM »
Hey man really appreciate it

So would say a hammer still fire even though the smartzone is named push and not weapon?
ALERT- Another WS coming up...
voted best bot builder two times and counting babayy. the best ra2 builder who has never won an actual tournament match
ReiAI pack for Ironforge
My drawings, and my webcomics
Why online PVP will save RA2
The problem with competitive IRL in RA2
I'm fine with hugging reier