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

Online apanx

Re: AI-ing (.py files, coding, nose-orienting R+D, and help)
« Reply #1240 on: August 09, 2016, 01:27:20 PM »
anyone know of a .py that works like fbs_2, but reverses direction while inverted and isn't a meltybrain .py?
Something like this ;)
https://github.com/apanx/RA2_AI/blob/master/SnS_2Invertible.py
« Last Edit: September 30, 2016, 08:39:19 AM by apanx »

Offline R01

  • Heavyweight
  • Posts: 769
  • Rep: 1
  • Awards BOTM Winner
    • View Profile
    • Awards
Re: AI-ing (.py files, coding, nose-orienting R+D, and help)
« Reply #1241 on: August 09, 2016, 05:26:54 PM »
Tried messing around with turn and turnspeed(which made it worse), turn didn't seem to help but what's odd is that if my bot starts in the player 1 spawn of the combat arena it drives in a straight line, player2's start point however does that shuffling.
Also what about the moving backwards straight/always face the AI and best place to get the most updated AI files?
Tournament History:
Showcases:
https://gametechmods.com/forums/index.php?topic=18882.0
https://gametechmods.com/forums/index.php?topic=19197.0

Offline 09090901

  • competitive irl
  • *
  • Posts: 1742
  • Rep: 22
  • anti-boomer super soldier
    • View Profile
    • Awards
Re: AI-ing (.py files, coding, nose-orienting R+D, and help)
« Reply #1242 on: August 09, 2016, 05:40:58 PM »
anyone know of a .py that works like fbs_2, but reverses direction while inverted and isn't a meltybrain .py?
Something like this ;)
https://gametechmods.com/forums/index.php?action=downloads;sa=view;down=265
Yeah, thanks apanx
DSL-IRL is the libtard’s meta. Go drink more soylent, retard! #BLUELIVESMATTER

Offline Badger

  • Permanent Artifact
  • Giga Heavyweight
  • Posts: 6318
  • Rep: 3
  • I wish to be with my people
  • Awards BOTM Winner Donated money for site hosting 2019
    • View Profile
    • Awards
Re: AI-ing (.py files, coding, nose-orienting R+D, and help)
« Reply #1243 on: August 09, 2016, 06:07:50 PM »
Tried messing around with turn and turnspeed(which made it worse), turn didn't seem to help but what's odd is that if my bot starts in the player 1 spawn of the combat arena it drives in a straight line, player2's start point however does that shuffling.
Also what about the moving backwards straight/always face the AI and best place to get the most updated AI files?
Can you send me the bot? I'd like to have a crack at it.
also lol at most toxic guy around calling others out on this sh**
Google Drive with my newer bots

Offline R01

  • Heavyweight
  • Posts: 769
  • Rep: 1
  • Awards BOTM Winner
    • View Profile
    • Awards
Re: AI-ing (.py files, coding, nose-orienting R+D, and help)
« Reply #1244 on: August 16, 2016, 07:19:04 AM »
Excuse me if this is rude, but can I finally get an answer to the "always face the bot even when moving away" problem as well as the py AI files?
I honestly don't care if my bot drives into hazards/the pit/off the arena as long as it doesn't stop moving in that position, facing the AI sideways, after moving backwards.

As for the AI files, I've heard that the AI Chart was the most up to date one/what's usually used, but that one's missing the popup(and probably a few other) files(by the way, said bot I'm trying to fix isn't a popup), isn't there a master py AI pack that everyone uses?
Tournament History:
Showcases:
https://gametechmods.com/forums/index.php?topic=18882.0
https://gametechmods.com/forums/index.php?topic=19197.0

Online apanx

Re: AI-ing (.py files, coding, nose-orienting R+D, and help)
« Reply #1245 on: August 16, 2016, 10:55:12 AM »
Not sure how many Python coders we still have active in the community. I do RA2 python for fun, and rewriting the entire drive logic to do something else than turning towards target and driving forward is going to time to do, mostly testing to make sure that everything works as intended. I have a rough idea of what commands in the available python commands would be useful, but there are a lot of questions remaining. For example, when should the bot move forward or backwards? Through what data would it decide that?
The most basic code would just be aiming for enemy and setting Forward to 100. The bot would always try facing the enemy and attempt to move forward. Take a look at the existing python files and try to do something like that. I am currently too busy to spend time on RA2, might maybe look at it during the end of next week. Hope you understand.

The closest thing to a master AI pack is the AI_essentials on Beetlebros' site.

Offline R01

  • Heavyweight
  • Posts: 769
  • Rep: 1
  • Awards BOTM Winner
    • View Profile
    • Awards
Re: AI-ing (.py files, coding, nose-orienting R+D, and help)
« Reply #1246 on: August 16, 2016, 02:06:40 PM »
Not sure how many Python coders we still have active in the community. I do RA2 python for fun, and rewriting the entire drive logic to do something else than turning towards target and driving forward is going to time to do, mostly testing to make sure that everything works as intended. I have a rough idea of what commands in the available python commands would be useful, but there are a lot of questions remaining. For example, when should the bot move forward or backwards? Through what data would it decide that?
The most basic code would just be aiming for enemy and setting Forward to 100. The bot would always try facing the enemy and attempt to move forward. Take a look at the existing python files and try to do something like that. I am currently too busy to spend time on RA2, might maybe look at it during the end of next week. Hope you understand.

The closest thing to a master AI pack is the AI_essentials on Beetlebros' site.
I didn't know this, take all the time you need as that's way more important than any of this AI stuff. I only wanted for this to not go under in all the posts here like it somewhat already did.
While having a new drive logic that instantly targets the enemy would be interesting(and definitely something I'd like to do later) I'd want to simply fix the "stuck" part so that the robot doesn't stop driving backwards, facing sideways.
Would you be ok if I sent you a video, showing what goes wrong, in PM?

I'll try to mess around with it for a bit, the Unstuck Tactic is inherited from Tactics.py? I've noticed that Eternal Flame(which is apparently based on Omni.py) doesn't have a Stuck Handler.
I checked AI_essentials, that doesn't really have that many, so I guess all those AI files were done on a version of another AI file, guess that means it's best to copy over something that works and ask if it doesn't work/if you can't find something?

I hope that this community can get this AI file chaos a bit more sorted/get more into python files because it seems like most only copy something that works from a similar bot and are then done with it. Thanks for doing all this for the community.
Tournament History:
Showcases:
https://gametechmods.com/forums/index.php?topic=18882.0
https://gametechmods.com/forums/index.php?topic=19197.0


Online apanx

Re: AI-ing (.py files, coding, nose-orienting R+D, and help)
« Reply #1248 on: August 16, 2016, 06:29:18 PM »
I didn't know this, take all the time you need as that's way more important than any of this AI stuff. I only wanted for this to not go under in all the posts here like it somewhat already did.
While having a new drive logic that instantly targets the enemy would be interesting(and definitely something I'd like to do later) I'd want to simply fix the "stuck" part so that the robot doesn't stop driving backwards, facing sideways.
Would you be ok if I sent you a video, showing what goes wrong, in PM?

I'll try to mess around with it for a bit, the Unstuck Tactic is inherited from Tactics.py? I've noticed that Eternal Flame(which is apparently based on Omni.py) doesn't have a Stuck Handler.
I checked AI_essentials, that doesn't really have that many, so I guess all those AI files were done on a version of another AI file, guess that means it's best to copy over something that works and ask if it doesn't work/if you can't find something?

I hope that this community can get this AI file chaos a bit more sorted/get more into python files because it seems like most only copy something that works from a similar bot and are then done with it. Thanks for doing all this for the community.
Check the AI files that come with the game. All AI inherit the SuperAI which is located in __init__.py in the AI folder. If you don't put in separate handlers, then the code in the SuperAI will be used.
Also check out the Tactics.py.

Offline R01

  • Heavyweight
  • Posts: 769
  • Rep: 1
  • Awards BOTM Winner
    • View Profile
    • Awards
Re: AI-ing (.py files, coding, nose-orienting R+D, and help)
« Reply #1249 on: August 16, 2016, 07:18:39 PM »
phil's semi-famous AI chart that comes with a bunch of .py files

All the .py files that come with Nar AI 2.7, IIRC some of them don't work.
What's the difference between 8459AI-Chart-2.3.rar and 43968459AI-Chart-23.rar? I checked your link and like the one I have it's still mentioning popup.py and missing it(like I said about a page ago), size of the rar also seems to be the same. I'm not annoyed, I just find it funny, was someone like "I'm tired of all those popups, there, file deleted, have fun"  :laughing one of the most used designs isn't there. Will check Nar AI 2.7.

Check the AI files that come with the game. All AI inherit the SuperAI which is located in __init__.py in the AI folder. If you don't put in separate handlers, then the code in the SuperAI will be used.
Also check out the Tactics.py.
Thanks, will do.
Tournament History:
Showcases:
https://gametechmods.com/forums/index.php?topic=18882.0
https://gametechmods.com/forums/index.php?topic=19197.0

Offline 090901

  • alcoholic in denial
  • *
  • Posts: 7006
  • Rep: 22
  • :mrgreen:
  • Awards Donated money for site hosting 2019 GTMCS2 Divison Winner GTMCS Division Winner
    • View Profile
    • Awards
Re: AI-ing (.py files, coding, nose-orienting R+D, and help)
« Reply #1250 on: August 16, 2016, 07:26:07 PM »
phil's semi-famous AI chart that comes with a bunch of .py files

All the .py files that come with Nar AI 2.7, IIRC some of them don't work.
What's the difference between 8459AI-Chart-2.3.rar and 43968459AI-Chart-23.rar? I checked your link and like the one I have it's still mentioning popup.py and missing it(like I said about a page ago), size of the rar also seems to be the same. I'm not annoyed, I just find it funny, was someone like "I'm tired of all those popups, there, file deleted, have fun"  :laughing one of the most used designs isn't there. Will check Nar AI 2.7.
No idea what's different. phil probably just forgot to include Popup.py when he complied it all like 6 years ago, plus that's before it was really popular to use.

Offline R01

  • Heavyweight
  • Posts: 769
  • Rep: 1
  • Awards BOTM Winner
    • View Profile
    • Awards
Re: AI-ing (.py files, coding, nose-orienting R+D, and help)
« Reply #1251 on: August 27, 2016, 06:31:13 PM »
I think I've found out the issue I had with my bot not turning.
Basically both bots would end up in a situation where one is pinned to the wall, countdown starts and the bot that's pinning drives away. Because the other bot couldn't move that much now, the countdown is still going on for it while it starts driving forwards. In the meantime the other bot that drived away stopped driving in a rotated position(because the code tells it to not move if the other bot is getting counted out before it), giving the pinned bot a free hit.
Guess I'll just have to remove the "do nothing when other bot gets counted out" part.
Tournament History:
Showcases:
https://gametechmods.com/forums/index.php?topic=18882.0
https://gametechmods.com/forums/index.php?topic=19197.0

Offline R01

  • Heavyweight
  • Posts: 769
  • Rep: 1
  • Awards BOTM Winner
    • View Profile
    • Awards
Re: AI-ing (.py files, coding, nose-orienting R+D, and help)
« Reply #1252 on: August 29, 2016, 12:46:08 PM »
More testing shows it's definitely that. Problem is, as far as I understand, that this is inherited from tactics.py or other files, and I have no idea how to overwrite that behaviour so that the robot keeps on targeting the AI, doesn't help that I only have like two days for the tournament, but please do the more important things in life first, doesn't matter if I lose this.
Tournament History:
Showcases:
https://gametechmods.com/forums/index.php?topic=18882.0
https://gametechmods.com/forums/index.php?topic=19197.0

Offline Trovaner

  • *
  • Posts: 1222
  • Rep: 32
    • View Profile
    • Awards
Re: AI-ing (.py files, coding, nose-orienting R+D, and help)
« Reply #1253 on: August 29, 2016, 08:25:47 PM »
Just copy the Unstuck class form Tactics.py, call it "Unstuck2", remove the check that you don't want, and add these two lines to the __init__ method of your AI.py:
Code: [Select]
self.RemoveTactic("Unstuck")
self.tactics.append(Tactics.Unstuck2(self, self.StuckHandler()))

Online apanx

Re: AI-ing (.py files, coding, nose-orienting R+D, and help)
« Reply #1254 on: August 29, 2016, 11:58:30 PM »
Put in your own Stuck Tactic in the py for your bot and don't mess with Tactics.py
https://gametechmods.com/forums/index.php?topic=2207.msg55033#msg55033

Code: [Select]
self.RemoveTactic("Unstuck")
self.tactics.append(Unstuck2(self, self.StuckHandler()))

Code: [Select]
   
class Unstuck2(AI.Tactic):
    name = "Unstuck2"
   
    def __init__(self, ai, unstuck_function):
        self.UnstuckFunction = unstuck_function
        AI.Tactic.__init__(self, ai)
       
    def Evaluate(self):
        # try to move if we're immobile and we either have no enemy
        #  or he was pinned after us
        self.priority = 200
       
        ai = self.ai
       
        # move to free ourselves unless our most recent enemy was stuck first
        if not ai.bImmobile: self.priority = -1000
        elif ai.GetID() in ai.immobile_list and \
            ai.enemy_id in ai.immobile_list and \
            ai.immobile_list[ai.GetID()] > ai.immobile_list[ai.enemy_id]:
                self.priority = -1000
       
    def Execute(self):
        self.ai.Throttle(0)
        self.ai.Turn(0)
        self.UnstuckFunction.next()
               
        return True

I have made a rudimentary Flee Tactic that always point the bot towards the enemy and drives backwards. It needs a lot of work before it is good, but still.
Code: [Select]
class Flee(AI.Tactic):
    name = "Flee"
   
    def Evaluate(self):
        self.priority = 0
        self.target_id, range = self.ai.GetNearestEnemy()
       
        # TODO: come up with a priority scale for "engaging"
       
        if self.target_id != None:
            self.priority = 170
        else:
            self.priority -= 1000
               
    def Execute(self):
        if self.target_id != None:
            self.ai.enemy_id = self.target_id
           
            # default turning & throttle off
            self.ai.Throttle(0)
            self.ai.Turn(0)
           
            target = plus.getLocation(self.target_id)
           
            # try to get out of range of chassis...
            if self.ai.GetDistanceToID(self.target_id) < 40 and self.ai.GetDistanceToID(self.target_id) > 10:
               # ... then aim for center of chassis
               h = self.ai.GetHeadingTo(target, False)
               self.ai.AimToHeading(h)
               self.ai.Throttle(-100)
            if self.ai.GetDistanceToID(self.target_id) < 10:
               h = self.ai.GetHeadingTo(target, False)
               self.ai.AimToHeading(h + math.pi / 2)
               self.ai.Throttle(-100)
            return True
        else:
            return False
« Last Edit: August 30, 2016, 04:09:29 PM by apanx »

Offline R01

  • Heavyweight
  • Posts: 769
  • Rep: 1
  • Awards BOTM Winner
    • View Profile
    • Awards
Re: AI-ing (.py files, coding, nose-orienting R+D, and help)
« Reply #1255 on: August 30, 2016, 03:43:52 PM »
Thanks guys, will try to build them into the py file.
I did read the tactics.py some time ago and remember reading about the unstuck handler, however when searching it yesterday I searched for time or countdown and couldn't find it because of that, think apanx also once mentioned how you can add something that then overwrites the default behaviour.

The driving backwards while always pointing towards the enemy tactic is nice, will try to work with it and try to learn this AI stuff so I won't have to ask "how to do X".
Tournament History:
Showcases:
https://gametechmods.com/forums/index.php?topic=18882.0
https://gametechmods.com/forums/index.php?topic=19197.0

Offline Philippa

  • The Queen of GTM
  • Giga Heavyweight
  • Posts: 6186
  • Rep: 0
  • ✊ Viva la Standard! ✊
  • Awards BOTM Winner
    • View Profile
    • Awards
Re: AI-ing (.py files, coding, nose-orienting R+D, and help)
« Reply #1256 on: October 02, 2016, 02:54:10 PM »

Code: [Select]
    list.append(("Drunken Robot Pornography","LittleMetalFriend",{'nose':math.pi,'radius':0.5,'range':99,'topspeed':100,'throttle':130,'turn':60,'turnspeed':2.5,'weapons':(0,)}))
https://gametechmods.com/uploads/files/5864Bot5.rar


Saw on a servo, dunno how to get the arm working right, needs to self-right, riddled with AGOD.
Anyone know how to help? Please and thank you.

Online apanx

Re: AI-ing (.py files, coding, nose-orienting R+D, and help)
« Reply #1257 on: October 05, 2016, 06:52:57 PM »
I think an adaptation of OmniServo would fit best, it might need some adjustments so work optimally for the bot.
https://github.com/apanx/RA2_AI/blob/master/OmniServo.py

Offline R01

  • Heavyweight
  • Posts: 769
  • Rep: 1
  • Awards BOTM Winner
    • View Profile
    • Awards
Re: AI-ing (.py files, coding, nose-orienting R+D, and help)
« Reply #1258 on: October 12, 2016, 02:52:58 PM »
(Image removed from quote.)
Code: [Select]
    list.append(("Drunken Robot Pornography","LittleMetalFriend",{'nose':math.pi,'radius':0.5,'range':99,'topspeed':100,'throttle':130,'turn':60,'turnspeed':2.5,'weapons':(0,)}))
https://gametechmods.com/uploads/files/5864Bot5.rar


Saw on a servo, dunno how to get the arm working right, needs to self-right, riddled with AGOD.
Anyone know how to help? Please and thank you.
Just curious, how did you get it working

Also OmniServo.py "verticvaly" just a minor detail :P
Tournament History:
Showcases:
https://gametechmods.com/forums/index.php?topic=18882.0
https://gametechmods.com/forums/index.php?topic=19197.0

Online apanx

Re: AI-ing (.py files, coding, nose-orienting R+D, and help)
« Reply #1259 on: October 12, 2016, 03:55:28 PM »