Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - apanx

Pages: 1 2 3 4 5 6 7 [8] 9 10
141
Tutorials and Tips / Robot Arena 2 AI Python repository on GitHub
« on: September 22, 2016, 05:36:31 PM »
https://github.com/apanx/RA2_AI

So everyone can find the most recent version of everything.
Fork, improve, do pull requests.
End the confusion of differing files with the same name.

142
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

143
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.

144
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.

145
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

146
The bot drives well manually? What AI does it use? Does that AI use the Engage tactic (like 90% of all AIs)
What might be happening is that the AI overshoots its intended heading as the bot turns too quick for the standard tickInterval. Either cap turnspeed, maximum Turn input, or increase tickInterval.

147
Add a StuckHandler and InvertHandler and put in your own code there. Standard is to move forward and backward when stuck or inverted. Some bot have InvertHandler code to fire SRMs or do other stuff. Facing the enemy when moving backwards leads to driving of the edge, a hazard, sticking into the wall.
Anyways, it would be easier to see whats wrong if you post the python file for the AI.

148
Can I get a DL for that Insanity Arena?
Sure
https://gametechmods.com/forums/index.php?action=downloads;sa=view;down=264

Great to see apanx posting more! The first 2 BFE bots are interesting, are they BFE'd to weight more or do they contain a ton of components?
See Youtube demo video.
Didn't know that this was 10 years already, ah the times when people didn't know about BFE.

I thought Oversized BFE Bot was a Tank but HOLY, I had no idea that Hammer of Judgement(who is using huge armor plates?!) was that big.
Wasn't the HD texture only done via importing a bigger one?
Think it's possible to build a too small robot by default but that one is even smaller.
How does the Battleship work ? I guess custom components?
Also the more controllers would be interesting to have, but how did you display them like that?(or does the game automatically do that once there are too many available?)
Insanity Arena reminds me of a super smash bros fangame stage, guess you launch them up and then change arena? would still be interesting to have.

I've heard about Meltybrain spinners before but never seen them, guess it uses a advanced AI that gives the right inputs at the right time?

How did you do the rapid fire cannon? Thought there's a component speed limit which is set by the component itself(also the cannon gets stuck a lot and I never got the magnet to work properly, so the only good cheatbot components are the flamethrowers?(and hovercrafts for popup immunity)) Armored Emergency was also nice.


Yes, just importing a larger than standard texture.
Hull is chassis, superstructure is custom components. Crashed the game when taking damage.
RA2 adapts the controller, but reset it to 3x3 when you try to edit it.
It starts as an empty field and the arena is created as an XtraObject
Yes, it is available on GTM. FBS.zip or something like that.
Magic, or BFE and some Python work. Just BFE 20 Cannons to the same servo, assign each a separate key. Make the AI fire each at a time real quick and aim using servo. BAM, instant machine gun. Would probably aim faster if it turned the entire bot, but made it have a turret just for fun.


149
It has been 10 years since the first How is such a thing possible? (or OMG)
Exposing the wonders of BFE to the public.
Archive, page 8-10 Missing
Print mode


I have still kept all pics.
Enjoy the old pics for inspiration:
BFE-Bot 1

BFE-Bot 2 - Download



Oversized BFE-Bot - Download




Multilayered BFE-Bot - (No download avaliable, yet)

The mesh seem to be generated according to chassis points and not specified mesh triangles in bot file if Graphics Detail is set to High. Set to Low get game to follow 3D model in .bot-file


Over 16 point chassis BFE-Bot - Download


Over 7 components chain BFE-Bot - Download


Component position edited BFE-Bot - Download


High resolution texture bot - Download


Too small BFE-Bot - Download
Was replaced by MicroBot, which is half the volume ;)


Battleship - Download


More controllers through BFE - Download


Insanity Arena - Download


Melty Brain AI - Download








MG Tank AI - Rapid fire of 20 Cannons - The AI and The Bot

150
By exploiting functions of the plus-class for fun and profit and code a custom Python AI.
Bind a button for secondary weapon. Use plus.GetHealth(BotID,0) to find HP and insert custom tactic to switch to when Enemy HP is 0 or all primary weapons are lost.
Use plus.getHeading(botID, useOffset) to get the Heading of the enemies, compare with your own to find their heading in comparison with yours.
Don't think there is a nice way to find time left, but maybe plus.getTimeElapsed could be used to change tactics based on time. A better way would be to maybe compare enemy points with your own and cower when in lead.
Use plus.AI.GetMotorAngle(MotorComponentID) to find the current servomotor angle. The first page in this thread explains usage.

There are a lot of good stuff buried in this thread, but it is worth reading through if you want to create custom AIs.

151
Count number of objects, the first one after the chassis has ID 1.
Or use the exporter, it is simpler.

152
if it's still not spinning up instantly then it might be because you don't have a range parameter. try a line like this:

    list.append(("Mega Gator","Omni",{'invertible':True,'range':99,'topspeed':99,'turnspeed':3,'throttle':130,'range':99,'weapons':(0,)}))

also use a button instead of a switch. with a button the ai will just keep turning it on and off.
Works now, thanks guys, thought that this parameter might be missing but didn't want to mess around more with it(already had the game crash like 10 times because of multiple errors), it is a button and not a switch(are there even switch controls for AI? think only buttons exist) full line is this:
list.append( ("Mega Gator", "ModSpinner", { 'range':99, 'weapons': (0,) }) )
The other parameters are optional so I didn't add them.(also you have range twice?) Do top/turn speed and throttle go past the values that the bot would normally be able to get or do they keep those limits/only work for slowing the bot down and making it more controlable?

Top speed and turn speed is just a max limit, they don't make the bot go faster than possible just for making the bot more controllable. Throttle, (and Max Turn) are capped at 100.

Would it be possible to create a bot that only starts using it's second weapon once the enemy hp reaches 0 or the first weapon(set via ID) breaks down?
Yes. It is possible.

153
You need the VB6 runtime to use the exporter
https://support.microsoft.com/en-us/kb/957924

155
Depends on what you want it to do.
Extend pistons to maximum when a bot is inside a smartzone or something else?

156
FBS is my old creation modded by Naryar to spin in the same direction no matter inverted status.
https://gametechmods.com/forums/index.php?topic=2191.msg54748#msg54748

FBS_1 and FBS_2 are made by Madiaba, not as good as FBS ;)

FBSFlame is FBS but with a Analog input named Flame pegged at 100.
FBSPlus is a FBS and can include a spinning weapon attached to an Switch control. It also uses a larger tickInterval to reduce CPU usage (and accuracy).
FBSInvertDir is FBSPlus but it spins in opposite direction when inverted.
FBSAnalog is a FBSInvertDir but using an Analog control instead of a Switch for the spinning weapon.





157
Not sure which ones you mean.
Please link them and I'll check them out.

158
What does nochassistime actually do?

It waits for specified time (1=0.5secs) before activating trigger if enemy robot is in zone, but the chassis is outside. If not specified, it is 1 sec .

Ok made the changes except the SmartZoneEvent thing.

The goal of the popup.py is hitting other bot only when the chassis is within the smart zone. Do you have info what does the arguments for this SmartZoneEvent method mean?
Yes but the code for SmartZoneEvent is messed up. It won't work. It is updated in the later pack. The changes in Tick won't do anything if SmartZoneEvent is not fixed.
direction, is 1 when stuff enters and -1 when stuff leaves zone
id, ID of smartzone, usually 1 for robots, unused in robot AI code, more important for arenas.
robot, ID of robot in zone
chassis, true if chassis of robot is in zone.

The newer Popup.py is better, but some of the old changes still apply if you want to separate Weapon from Srimech triggers.

159
This code is messed up. It contains superfluous stuff under Tick. You can't specify Weapon trigger separately from Srimech trigger. SmartZoneEvent is only triggered when something enters or leaves the Smartzone.
If you want to use it. Remove this part
Code: [Select]
    def SmartZoneEvent(self, direction, id, robot, chassis):
        if id == 1 and self.weapons:
            if chassis:
                if direction == 1:
                    for trigger in self.triggers1: self.Input(trigger, 0, 1)
        return True

Replace this part
Code: [Select]
    def Tick(self):
        # fire weapon


        targets = [x for x in self.sensors.itervalues() if x.contacts > 0 \
                and not plus.isDefeated(x.robot)]
                       
        bReturn = AI.SuperAI.Tick(self)
       
        return bReturn

With this
Code: [Select]
    def Tick(self):
        # fire weapon
        if self.weapons:
            targets = [x for x in self.sensors.itervalues() if x.contacts > 0 \
                and not plus.isDefeated(x.robot)]
                       
            if len(targets) > 0:             
                for trigger in self.triggers1: self.Input(trigger, 0, 1)
           
        return AI.SuperAI.Tick(self)

Also, separate Weapon triggers from Srimech triggers, Replace this:
Code: [Select]
        if 'triggers' in args: self.triggers2 = args['triggers']With
Code: [Select]
        if 'srimech' in args: self.triggers2 = args['srimech']
And make smartzone name changeable in bindings, replace this:
Code: [Select]
        if 'zone' in args: self.zone = args['zone']With
Code: [Select]
        if 'zone' in args: self.zone1 = args['zone']

160
Hi there,

I'm using popup.py for my popup bot (which I took from the starcore 4 ai pack, I don't know where can I find the latest version of it), and noticed that weapons fire only when the chassis of the opponent enters the smart zone but not when the chassis is inside it. This means if my popup bot shoves up the opponent before the razors retract, the opponent can sit on the top of my bot without firing the weapons.

Is it possible to fix this, somehow or do you know an update version of this file?
Let me have a look at the popup.py

Pages: 1 2 3 4 5 6 7 [8] 9 10