Author Topic: How to do Evasive Manuevers PY?  (Read 1525 times)

Offline Gigafrost

  • *
  • Posts: 805
  • Rep: 0
  • You'll never know what I'll think of next.
    • View Profile
    • Awards
How to do Evasive Manuevers PY?
« on: March 12, 2009, 08:04:58 AM »
This has been lightly discussed, but how would we go about emulating a code that makes the enemy avoid contact with the user or other bots after all it's weapons are broken off?
 
I think it has something to do with the engage command or the code which makes the AI go towards the opponent. Would reciporicalizing the values have an opposite effect?
 
To get a better understanding of my reasoning:
 
Before Weapons are broken off: Bot engages battle with opponent through approaching and attacking
 
After Weapons are broken off: Bot switches to "flee" instead of "shove" and avoids the opponent for the rest of the match

Offline Sage

  • *
  • Posts: 6179
  • Rep: 11
  • RA2 Wizard & GTM's Favorite Stock Builder 2015
  • Awards Sage's Favorite BOTM Winner
    • View Profile
    • Awards
How to do Evasive Manuevers PY?
« Reply #1 on: March 12, 2009, 03:16:02 PM »
Madiaba actually AIed a bot with something like this for gumba. his LW i believe.
You got my vote for RA2 Wizard. Always and forever.

Offline Trovaner

  • *
  • Posts: 1222
  • Rep: 32
    • View Profile
    • Awards
How to do Evasive Manuevers PY?
« Reply #2 on: March 14, 2009, 12:11:40 AM »
Madiaba and me were discussing this on MSN a couple weeks ago and for the most part he has made coding that tells the bot to avoid the opponent while staying within a certain distance from the center of the arena. Some ideas that we had that I'm still programming for this include: staying away from hazards, keeping an eye on more than one bot at a time, and figuring out where the real walls are and how to avoid them.

Offline System32

  • *
  • Posts: 4663
  • Rep: 4
  • Reality
    • View Profile
    • Awards
How to do Evasive Manuevers PY?
« Reply #3 on: March 14, 2009, 09:15:25 AM »
It seems to me we are working towards a near human AI. Perhaps this could be triggered by something else, like if you have low health and the oppponent is too close?
Put this onto your signature if you were part of this crappy fad in '03.

Offline Madiaba

How to do Evasive Manuevers PY?
« Reply #4 on: March 14, 2009, 01:04:25 PM »
S-32, self/opponent's health, and opponent range are already in the equation...
 
^As Trov. said.^
 
But part of what is still NOT clear, is whether or not to write it in an AI.py or in the Tactics. And, since CB is guiding DSL3, it is his call about tweaking the Tactics...
 
I'll PM you GIG....
 
..
« Last Edit: March 14, 2009, 05:05:03 PM by Madiaba »
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...

Offline philetbabe

  • *
  • Posts: 497
  • Rep: 2
  • Drop D
    • View Profile
    • Awards
How to do Evasive Manuevers PY?
« Reply #5 on: March 16, 2009, 07:23:35 AM »
Quote from: Madiaba;30892
S-32, self/opponent's health, and opponent range are already in the equation...


Hi there, i'm interested in having a look at yout coding Mad,

i've tried to make a tactic with evasive  Manuevers, but, even if it is still a draft, i'm a little bit dispointed. Help me improve it :
Code: [Select]

class AvoidFoe(AI.Tactic):
    name = "AvoidFoe"

    def __init__(self, ai):
        AI.Tactic.__init__(self, ai)
        goforward = False
   
    def Evaluate(self):
        #do not bother : high priority, it is a draft!
        self.priority = 300
        self.target_id, range = self.ai.GetNearestEnemy()
           
    def Execute(self):
        # get information about self and ennemy :
        if self.target_id != None:
            a = Arenas.currentArena
            target_loc = plus.getLocation(self.target_id)
            self_loc = self.ai.GetLocation()
            #
            dir = vector3(target_loc) - vector3(self_loc)
            bestDist = dir.length()
            dir.normalize()
            dir.x, dir.z = dir.z, dir.x
            factorD = [5,  4,  3, 2, -5, -4, -3 -2]
            isOk = False
            bestloc = self_loc
            for d in factorD:
                dest = vector3(self_loc) + dir * d
                if self.ai.IsStraightPathClear(self_loc, dest.asTuple()):
                        newDist = (dest - vector3(target_loc)).length()
                        if abs(newDist) > abs( bestDist ):
                            bestloc = dest
                            bestDist = newDist
                            enAvantToute = ( newDist > 0 )
                            isOk = True
            if isOk: self.ai.DriveToLocation(bestloc.asTuple(),enAvantToute)
        return True


Offline Madiaba

How to do Evasive Manuevers PY?
« Reply #6 on: March 16, 2009, 10:04:39 AM »
Well Phil, most of my coding was done in the AI.py, and not in the Tactics.py...where I think it should be done (and it looks like you agree). I talked with Trov as he mentioned, and also CB about this yesterday. What I can roughly surmise so far is a Tactic that:
1. keeps the nose pointing toward nearestenemy (so keep regular LeftRight steering in situ).
2. but will (a) reverse directly away from nearestenemy for only a certain distance/'range', or (b) pick a location in back of it to back up to(like Rammer.py).
3. check for 'IsStraightPathClear' (don't know if this c for walls yet)
4. keep the bot proximal to the center of the arena (via basic getLocation) so it doesn't get trapped.
 
I'll look at your tweak here and get back...
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...

Offline Gigafrost

  • *
  • Posts: 805
  • Rep: 0
  • You'll never know what I'll think of next.
    • View Profile
    • Awards
How to do Evasive Manuevers PY?
« Reply #7 on: March 16, 2009, 03:08:49 PM »
Sounds good guys, I await for it to be finished. I have been dreaming of this PY for quite some time :)