Author Topic: AI-ing (.py files, coding, nose-orienting R+D, and help)  (Read 159746 times)

Offline JoeBlo

Re: AI-ing (.py files, coding, R+D, and help)
« Reply #220 on: December 13, 2009, 10:21:17 AM »
Im going to say its possible as Mad and Trov got robots to do that for Whams WRL arena didnt they ?

there is not one already in existence as far as I know

Offline Somebody

  • *
  • Posts: 7200
  • Rep: 13
  • CP: +2
    • SomebodyofGTM
    • View Profile
    • My site
    • Awards
Re: AI-ing (.py files, coding, R+D, and help)
« Reply #221 on: December 13, 2009, 10:24:53 AM »
I was thinking that that type of py may be the best way to go for my CC3 bot.
I built that big robot on that TV show that time


Offline G.K.

  • *
  • Posts: 12157
  • Rep: 10
  • Striving for a good personal text since 1994.
    • View Profile
    • Awards
Re: AI-ing (.py files, coding, R+D, and help)
« Reply #222 on: December 13, 2009, 10:25:34 AM »
Does anybody know what went wrong with my .py?
My above post explains everything about everything.

Host of: Wheely Tag, Back To The Beginnings, BTTB 2, BTTB 3, BTTB 4, & BTTB V.

Heavy Metal: Champion (Mockery of the Whole Concept)
Robotic International Wars Series 1: Champion (Minifridge 6)
RA2 Team Championships 1 & 2: Champion (High Speed Train & Upthrust - as part of Naryar's Not Quite Evil Council of Doom)

Runner Up in: The Amazing Rage (Team Fedex), R0B0NOVA (Zaphod Stock), Steel Warzone (Inception of Instability), Box of Nightmares (Gicquel), Wheely Tag (Minifridge the Second)

Clash Cubes IV: 5th place (Fretless)
BBEANS 6: Rumble Winner & 6th Place (Minifridge 4)

Online apanx

Re: AI-ing (.py files, coding, R+D, and help)
« Reply #223 on: December 14, 2009, 03:15:10 PM »
Is there a possibility of a .py that uses the moving action of the FBS.py to just go to the center of the arena and spin there, instead of chasing the other bot?


Yes it is possible. You have to make a custom tactic for it though that has the target set to 0,0,0. I made a thread before about how to integrate custom tactics in the AI python files.
Sorry to DP, but I want to show everyone what I did. I added this to popup.py after the bit about not firing until the enemy hits the body:

       if self.weapons:
            targets = [x.robot for x in self.sensors.itervalues() if x.contacts > 0 \
                and not plus.isDefeated(x.robot)]
           
            fire = False
            for bot in targets:
                if not plus.isUpsideDown(bot) or self.CanDriveUpsideDown(bot):
                    fire = True
               
            if fire: self.Input(self.trigger, 0, 1)
                                   
        bReturn = AI.SuperAI.Tick(self)
       
        return bReturn

    def CanDriveUpsideDown(self, bot):
        MOVE_THRESHOLD = 3.0 <- Tried increasing that to make it less sensitive to random movments?
       
        if bot in self.upTrack:
            t = self.upTrack[bot]
            if t.invertible: return True
            else:
                # check to see if he's moved recently
                position = plus.getLocation(bot)
                time = plus.getTimeElapsed()
                if time - t.last_time > 10:
                    # this record is too old to be reliable
                    t.last_time = time
                    t.last_position = position
                    return False
                v0 = vector3(t.last_position)
                v1 = vector3(position)
                if (v1-v0).length() > MOVE_THRESHOLD: t.invertible = True
                return t.invertible
        else:
            t = UpsideDownTracker()
            t.last_position = plus.getLocation(bot)
            t.last_time = plus.getTimeElapsed()
            self.upTrack[bot] = t
           
            return False


The bot still attacks upside down robots. What have I done wrong?

Offline G.K.

  • *
  • Posts: 12157
  • Rep: 10
  • Striving for a good personal text since 1994.
    • View Profile
    • Awards
Re: AI-ing (.py files, coding, R+D, and help)
« Reply #224 on: December 14, 2009, 03:17:19 PM »
Apanx! I've heard a lot about you. Thank you so much for that bot exporter, it's really useful. I'll try your suggestion out now.
My above post explains everything about everything.

Host of: Wheely Tag, Back To The Beginnings, BTTB 2, BTTB 3, BTTB 4, & BTTB V.

Heavy Metal: Champion (Mockery of the Whole Concept)
Robotic International Wars Series 1: Champion (Minifridge 6)
RA2 Team Championships 1 & 2: Champion (High Speed Train & Upthrust - as part of Naryar's Not Quite Evil Council of Doom)

Runner Up in: The Amazing Rage (Team Fedex), R0B0NOVA (Zaphod Stock), Steel Warzone (Inception of Instability), Box of Nightmares (Gicquel), Wheely Tag (Minifridge the Second)

Clash Cubes IV: 5th place (Fretless)
BBEANS 6: Rumble Winner & 6th Place (Minifridge 4)

Offline G.K.

  • *
  • Posts: 12157
  • Rep: 10
  • Striving for a good personal text since 1994.
    • View Profile
    • Awards
Re: AI-ing (.py files, coding, R+D, and help)
« Reply #225 on: December 14, 2009, 03:26:16 PM »
DP. Unfortunately it still goes after upside down bots.
My above post explains everything about everything.

Host of: Wheely Tag, Back To The Beginnings, BTTB 2, BTTB 3, BTTB 4, & BTTB V.

Heavy Metal: Champion (Mockery of the Whole Concept)
Robotic International Wars Series 1: Champion (Minifridge 6)
RA2 Team Championships 1 & 2: Champion (High Speed Train & Upthrust - as part of Naryar's Not Quite Evil Council of Doom)

Runner Up in: The Amazing Rage (Team Fedex), R0B0NOVA (Zaphod Stock), Steel Warzone (Inception of Instability), Box of Nightmares (Gicquel), Wheely Tag (Minifridge the Second)

Clash Cubes IV: 5th place (Fretless)
BBEANS 6: Rumble Winner & 6th Place (Minifridge 4)

Offline System32

  • *
  • Posts: 4663
  • Rep: 4
  • Reality
    • View Profile
    • Awards
Re: AI-ing (.py files, coding, R+D, and help)
« Reply #226 on: December 14, 2009, 05:26:42 PM »
Created a new AI:
 
Code: [Select]
from __future__ import generators
import plus
import AI
from AI import vector3
import Arenas
import Gooey
import math
import Tactics
class Popup(AI.SuperAI):
    "Like Plow, but waits for chassis contact before firing the weapon.  If chassis is not found by a certain time, then fires anyway."
    # Use variable 'NoChassisTime' in Bindings.py to set the amount of time in seconds the AI will wait to find the chassis before giving up and firing, when there are components in the smart zone.
    name = "CheapPopup"
    def __init__(self, **args):
        AI.SuperAI.__init__(self, **args)
               
        self.zone1 = "weapon"
        self.triggers1 = ["Fire"]
        self.triggers2 = ["Srimech"]
        self.botinzone = 0
        self.compinzone = 0
        self.comptimer = 0
        self.NoChassisTime = 8
        if 'zone' in args: self.zone = args['zone']
       
        if 'triggers' in args: self.triggers1 = args['triggers']
        if 'triggers' in args: self.triggers2 = args['triggers']
        if 'NoChassisTime' in args: self.NoChassisTime = args.get('NoChassisTime') * 4
        self.tactics.append(Tactics.Engage(self))
        self.tactics.append(Tactics.Charge(self))
        self.tactics.append(Tactics.Shove(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.zone1, 1)
           
        return AI.SuperAI.Activate(self, active)
    def Tick(self):
        # fire weapon
        targets = [x for x in self.sensors.itervalues() if x.contacts > 0 \
                and not plus.isDefeated(x.robot)]
       
        # if a component is in the smart zone but not the chassis, wait to find chassis before firing weapons
        if self.compinzone == 1 and self.botinzone == 0:
            self.comptimer += 1
           
        if self.botinzone == 1:
            self.comptimer = 0
           
        if self.weapons and (self.botinzone == 1 or (self.comptimer >= self.NoChassisTime and self.compinzone == 1)):
            for trigger in self.triggers1: self.Input(trigger, 0, 1)
                       
        bReturn = AI.SuperAI.Tick(self)
       
        return bReturn
    def InvertHandler(self):
        # fire all weapons once per second (until we're upright!)
        while 1:
            for trigger in self.triggers2:
                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 Disable(self,btarget):
        # Disables opponent by charging it at an angle
        # we use a different angle (depending on the size of the opponent!)
        # if target is equal in size, the plow weapon charges are more direct
        if btarget > self: self.Turn(79)
        else: self.Turn(-79)
        if btarget < self: self.Turn(35)
        else: self.Turn(-35)
        if btarget == self: self.Turn(90)
        else: self.Turn(-90)
        if self.target: self.Turn(360)
       
        return AI.SuperAI.Disable(self, btarget)
               
    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 and self.weapons:
            if robot > 0:
                if direction == 1:
                    self.compinzone = 1
                    if chassis:
                        self.botinzone = 1
                if direction == -1:
                    self.compinzone = 0
                    if chassis:
                        self.botinzone = 0
        return True
   
AI.register(CheapPopup)

Problem: Crashes RA2, and I don't know how. Help?
Put this onto your signature if you were part of this crappy fad in '03.

Online apanx

Re: AI-ing (.py files, coding, R+D, and help)
« Reply #227 on: December 14, 2009, 11:57:56 PM »
Created a new AI:
 
        return AI.SuperAI.LostComponent(self, id)
    def Disable(self,btarget):  <- Seems to be a space too little, try changing to def Disable(self, btarget):
        # Disables opponent by charging it at an angle
 
Problem: Crashes RA2, and I don't know how. Help?

Check that part, there seems to be a space missing. What I see immediately. Might discover something more later.

Offline JoeBlo

Re: AI-ing (.py files, coding, R+D, and help)
« Reply #228 on: December 15, 2009, 12:17:08 AM »
those making .py's what program are you using ?

if you are making them in notepad I will ask you to stop right now :P

Get Python and edit them with IDLE (comes with python) it has a feature that will check your py for errors and tell you whats wrong  ;)

Offline G.K.

  • *
  • Posts: 12157
  • Rep: 10
  • Striving for a good personal text since 1994.
    • View Profile
    • Awards
Re: AI-ing (.py files, coding, R+D, and help)
« Reply #229 on: December 15, 2009, 12:22:25 AM »
What will that popup do? Attack from the rear?

Oh and Joe, when I download python, how do I get the .exe and where is IDLE?
My above post explains everything about everything.

Host of: Wheely Tag, Back To The Beginnings, BTTB 2, BTTB 3, BTTB 4, & BTTB V.

Heavy Metal: Champion (Mockery of the Whole Concept)
Robotic International Wars Series 1: Champion (Minifridge 6)
RA2 Team Championships 1 & 2: Champion (High Speed Train & Upthrust - as part of Naryar's Not Quite Evil Council of Doom)

Runner Up in: The Amazing Rage (Team Fedex), R0B0NOVA (Zaphod Stock), Steel Warzone (Inception of Instability), Box of Nightmares (Gicquel), Wheely Tag (Minifridge the Second)

Clash Cubes IV: 5th place (Fretless)
BBEANS 6: Rumble Winner & 6th Place (Minifridge 4)

Offline JoeBlo

Re: AI-ing (.py files, coding, R+D, and help)
« Reply #230 on: December 15, 2009, 12:32:10 AM »
if python is installed then right click on a .py and you will see in that list that comes up "Edit With IDLE"

when in IDLE you can hit "Ctrl + X" to check for errors

it makes it a lot easier, my mentor showed me it :P (wonder who that is ?)

as for PopUp.py as far as I know it will only fire weapons if a chassis is in the smartzone, useful for fighting HS robots

Offline G.K.

  • *
  • Posts: 12157
  • Rep: 10
  • Striving for a good personal text since 1994.
    • View Profile
    • Awards
Re: AI-ing (.py files, coding, R+D, and help)
« Reply #231 on: December 15, 2009, 12:36:52 AM »
I downloaded it and extracted the files but cannot find an installer.
My above post explains everything about everything.

Host of: Wheely Tag, Back To The Beginnings, BTTB 2, BTTB 3, BTTB 4, & BTTB V.

Heavy Metal: Champion (Mockery of the Whole Concept)
Robotic International Wars Series 1: Champion (Minifridge 6)
RA2 Team Championships 1 & 2: Champion (High Speed Train & Upthrust - as part of Naryar's Not Quite Evil Council of Doom)

Runner Up in: The Amazing Rage (Team Fedex), R0B0NOVA (Zaphod Stock), Steel Warzone (Inception of Instability), Box of Nightmares (Gicquel), Wheely Tag (Minifridge the Second)

Clash Cubes IV: 5th place (Fretless)
BBEANS 6: Rumble Winner & 6th Place (Minifridge 4)

Offline JoeBlo

Re: AI-ing (.py files, coding, R+D, and help)
« Reply #232 on: December 15, 2009, 02:09:18 AM »
http://www.python.org/download/

first link, then just run the msi file  ;)

Offline G.K.

  • *
  • Posts: 12157
  • Rep: 10
  • Striving for a good personal text since 1994.
    • View Profile
    • Awards
Re: AI-ing (.py files, coding, R+D, and help)
« Reply #233 on: December 15, 2009, 10:20:08 AM »
I can't download that link, but

I downloaded this one: http://www.python.org/ftp/python/3.1.1/Python-3.1.1.tar.bz2
My above post explains everything about everything.

Host of: Wheely Tag, Back To The Beginnings, BTTB 2, BTTB 3, BTTB 4, & BTTB V.

Heavy Metal: Champion (Mockery of the Whole Concept)
Robotic International Wars Series 1: Champion (Minifridge 6)
RA2 Team Championships 1 & 2: Champion (High Speed Train & Upthrust - as part of Naryar's Not Quite Evil Council of Doom)

Runner Up in: The Amazing Rage (Team Fedex), R0B0NOVA (Zaphod Stock), Steel Warzone (Inception of Instability), Box of Nightmares (Gicquel), Wheely Tag (Minifridge the Second)

Clash Cubes IV: 5th place (Fretless)
BBEANS 6: Rumble Winner & 6th Place (Minifridge 4)

Offline System32

  • *
  • Posts: 4663
  • Rep: 4
  • Reality
    • View Profile
    • Awards
Re: AI-ing (.py files, coding, R+D, and help)
« Reply #234 on: December 16, 2009, 09:23:09 AM »
Yeah there were quite a few errors. I fixed them (I think...).
Put this onto your signature if you were part of this crappy fad in '03.

Offline System32

  • *
  • Posts: 4663
  • Rep: 4
  • Reality
    • View Profile
    • Awards
Re: AI-ing (.py files, coding, R+D, and help)
« Reply #235 on: December 16, 2009, 11:41:50 AM »
New problem: Won't turn!
 
Code: [Select]
from __future__ import generators
import plus
import AI
from AI import vector3
import Arenas
import Gooey
import math
import Tactics
class Cheap(AI.SuperAI):
    # "Like Omni, but waits for chassis contact before firing the weapon. If chassis is not found by a certain time, then fires anyway. it also attacks from the side, like the Plow AI."
    # Use variable 'NoChassisTime' in Bindings.py to set the amount of time in seconds the AI will wait to find the chassis before giving up and firing, when there are components in the smart zone.
    name = "Cheap"
    def __init__(self, **args):
        AI.SuperAI.__init__(self, **args)
               
        self.zone1 = "weapon"
        self.triggers1 = ["Fire"]
        self.triggers2 = ["Srimech"]
        self.botinzone = 0
        self.compinzone = 0
        self.comptimer = 0
        self.NoChassisTime = 4
        if 'zone' in args: self.zone = args['zone']
       
        if 'triggers' in args: self.triggers1 = args['triggers']
        if 'triggers' in args: self.triggers2 = args['triggers']
        if 'NoChassisTime' in args: self.NoChassisTime = args.get('NoChassisTime') * 4
        self.tactics.append(Tactics.Shove(self))
        self.tactics.append(Tactics.Charge(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.zone1, 1)
           
        return AI.SuperAI.Activate(self, active)
    def Tick(self):
        # fire weapon
        targets = [x for x in self.sensors.itervalues() if x.contacts > 0 \
                and not plus.isDefeated(x.robot)]
       
        # if a component is in the smart zone but not the chassis, wait to find chassis before firing weapons
        if self.compinzone == 1 and self.botinzone == 0:
            self.comptimer += 1
           
        if self.botinzone == 1:
            self.comptimer = 0
           
        if self.weapons and (self.botinzone == 1 or (self.comptimer >= self.NoChassisTime and self.compinzone == 1)):
            for trigger in self.triggers1: self.Input(trigger, 0, 1)
                       
        bReturn = AI.SuperAI.Tick(self)
       
        return bReturn
    def InvertHandler(self):
        # fire all weapons once per second (until we're upright!)
        while 1:
            for trigger in self.triggers2:
                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 == "Charge"]
            if len(tactic) > 0:
                self.tactics.remove(tactic[0])
               
                self.tactics.append(Tactics.Shove(self))
           
        return AI.SuperAI.LostComponent(self, id)
    def Disable(self, btarget):
        # Disables opponent by charging it at an angle
        # we use a different angle (depending on the size of the opponent!)
        # if target is equal in size, the plow weapon charges are more direct
        if btarget > self: self.Turn(79)
        else: self.Turn(-79)
        if btarget < self: self.Turn(35)
        else: self.Turn(-35)
        if btarget == self: self.Turn(90)
        else: self.Turn(-90)
        if self.target: self.Turn(360)
       
        return AI.SuperAI.Disable(self, btarget)
               
    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 and self.weapons:
            if robot > 0:
                if direction == 1:
                    self.compinzone = 1
                    if chassis:
                        self.botinzone = 1
                if direction == -1:
                    self.compinzone = 0
                    if chassis:
                        self.botinzone = 0
        return True
   
AI.register(Cheap)
Put this onto your signature if you were part of this crappy fad in '03.

Offline G.K.

  • *
  • Posts: 12157
  • Rep: 10
  • Striving for a good personal text since 1994.
    • View Profile
    • Awards
Re: AI-ing (.py files, coding, R+D, and help)
« Reply #236 on: December 16, 2009, 11:48:04 AM »
How do you make code appear in the code scroll box thing?
My above post explains everything about everything.

Host of: Wheely Tag, Back To The Beginnings, BTTB 2, BTTB 3, BTTB 4, & BTTB V.

Heavy Metal: Champion (Mockery of the Whole Concept)
Robotic International Wars Series 1: Champion (Minifridge 6)
RA2 Team Championships 1 & 2: Champion (High Speed Train & Upthrust - as part of Naryar's Not Quite Evil Council of Doom)

Runner Up in: The Amazing Rage (Team Fedex), R0B0NOVA (Zaphod Stock), Steel Warzone (Inception of Instability), Box of Nightmares (Gicquel), Wheely Tag (Minifridge the Second)

Clash Cubes IV: 5th place (Fretless)
BBEANS 6: Rumble Winner & 6th Place (Minifridge 4)

Offline System32

  • *
  • Posts: 4663
  • Rep: 4
  • Reality
    • View Profile
    • Awards
Re: AI-ing (.py files, coding, R+D, and help)
« Reply #237 on: December 16, 2009, 12:09:51 PM »
Magic.

That, and the # button in reply mode.
Put this onto your signature if you were part of this crappy fad in '03.

Offline G.K.

  • *
  • Posts: 12157
  • Rep: 10
  • Striving for a good personal text since 1994.
    • View Profile
    • Awards
Re: AI-ing (.py files, coding, R+D, and help)
« Reply #238 on: December 16, 2009, 12:10:58 PM »
Thanks. I'd definitely be interested in using your .py if you can fix the problems it has.
My above post explains everything about everything.

Host of: Wheely Tag, Back To The Beginnings, BTTB 2, BTTB 3, BTTB 4, & BTTB V.

Heavy Metal: Champion (Mockery of the Whole Concept)
Robotic International Wars Series 1: Champion (Minifridge 6)
RA2 Team Championships 1 & 2: Champion (High Speed Train & Upthrust - as part of Naryar's Not Quite Evil Council of Doom)

Runner Up in: The Amazing Rage (Team Fedex), R0B0NOVA (Zaphod Stock), Steel Warzone (Inception of Instability), Box of Nightmares (Gicquel), Wheely Tag (Minifridge the Second)

Clash Cubes IV: 5th place (Fretless)
BBEANS 6: Rumble Winner & 6th Place (Minifridge 4)

Offline System32

  • *
  • Posts: 4663
  • Rep: 4
  • Reality
    • View Profile
    • Awards
Re: AI-ing (.py files, coding, R+D, and help)
« Reply #239 on: December 16, 2009, 04:31:38 PM »
Heh, the problem was in the test bots!
Put this onto your signature if you were part of this crappy fad in '03.