How can make a AI like a pro?

whiteghoul

New Member
Reaction score
0
while i'm playing a custom maps i have created and set them alliances of my AI of 3 players of them and 1 for user which is me....

When i'm in battle a long time playing game i figure out that AI does not build any kind of structure like there to defend her base....

always there build is only there barracks and factory and train some marines.....I can't see buid there bunker to defend them

Is there another to make AI so powerful just like human how to build like a pro?...
 

tom_mai78101

The Helper Connoisseur / Ex-MineCraft Host
Staff member
Reaction score
1,632
Requirements:

1. Vast amount of time.
2. Vast amount of energy.
3. Vast amount of determination.
4. Normal to Good amount of knowledge of the AI Editor.
5. Logic skills.
6. Need a lot of replays from different people of different skills.

Check to make sure you have all of them. You'll want to model the build orders from the build orders used by the players in the replays, as they act as references.

The time, energy, and determination are the holy trinity to get you going for as long as it can. You'll want to do some more researching on the AI Editor, and make sure you know what does what. After that, try applying some logic skills to the AI, so that it would think like a pro.

Any more problems? Keep posting here. I can't help you much, as my computer isn't ready.
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
AI's are extremely complicated, and they do take a lot of work. The more intelligent/complicated the AI is, the more it will take. You'll probably work best if you write functions that analyze the game constantly. You'll need to create tons of events, so you'll know when something changes the game and the odds are tipped in favor of one action or another.

I was working on a tutorial for non-melee AI (thought it still pertains to melee) here. I never quite finished it, but some of the information may still help you out.
 

whiteghoul

New Member
Reaction score
0
AI's are extremely complicated, and they do take a lot of work. The more intelligent/complicated the AI is, the more it will take. You'll probably work best if you write functions that analyze the game constantly. You'll need to create tons of events, so you'll know when something changes the game and the odds are tipped in favor of one action or another.

I was working on a tutorial for non-melee AI (thought it still pertains to melee) here. I never quite finished it, but some of the information may still help you out.

Can you give me some sample of trigger of AI?
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
Can you give me some sample of trigger of AI?

I don't yet have SC2, but I could show you a bit of WC3 code.

Some heavily bloated vJass (everything is a struct ;) ):

JASS:
library Warrior uses Systems

    globals
        integer WARRIOR_BATTLE_CRY_MANA_MIN_REQ = 80
        
        UnitType WARRIOR
        
        Ability WARRIOR_RAMPAGE
        Ability WARRIOR_SLASH
        Ability WARRIOR_BATTLE_CRY
        Ability WARRIOR_CHARGE
        Ability WARRIOR_BLOOD_RAGE
    endglobals

    struct Warrior extends UnitType
        
        static method onEnterFlagRange takes Unit this, Flag which returns nothing
            call IssueTargetOrder(this.unit,"smart",which.whichFlag)
        endmethod
        
        static method engage takes Unit this, Unit target returns nothing
            local real dist = DistanceBetweenXY(this.x,this.y,target.x,target.y)
            if dist > 600 then
                if this.canCast(WARRIOR_CHARGE) then
                    call IssueTargetOrder(this.unit,WARRIOR_CHARGE.order,target.unit)
                elseif this > target then
                    if GetUnitAbilityLevel(this.unit,WARRIOR_BATTLE_CRY.whichBuff) == 0 and this.canCast(WARRIOR_BATTLE_CRY) and this.mana > WARRIOR_BATTLE_CRY_MANA_MIN_REQ then
                        call IssueImmediateOrder(this.unit,WARRIOR_BATTLE_CRY.order)
                    elseif this.canCast(WARRIOR_SLASH) then
                        call IssueTargetOrder(this.unit,WARRIOR_SLASH.order,target.unit)
                    else
                        call this.attack(target)
                    endif
                else
                    call Debug.PlaceHolder(this.name + " is attempting to flee from " + target.name)
                endif
            elseif dist > 400 then
                if this.canCast(WARRIOR_BATTLE_CRY) and GetUnitAbilityLevel(this.unit,WARRIOR_BATTLE_CRY.whichBuff) == 0 and this.mana > WARRIOR_BATTLE_CRY_MANA_MIN_REQ then
                    call IssueImmediateOrder(this.unit,WARRIOR_BATTLE_CRY.order)
                elseif this.canCast(WARRIOR_SLASH) then
                    call IssueTargetOrder(this.unit,WARRIOR_SLASH.order,target.unit)
                else
                    call this.attack(target)
                endif
            else
                if this.canCast(WARRIOR_SLASH) then
                    call IssueTargetOrder(this.unit,WARRIOR_SLASH.order,target.unit)
                else
                    call this.attack(target)
                endif
            endif
        endmethod

        private static method onInit takes nothing returns nothing
            set WARRIOR = Warrior.create('E003')
            
            set WARRIOR_RAMPAGE = Ability.create('A01I',"stomp",TARGET_TYPE_NONE,50,50,50,50)
            set WARRIOR_SLASH = Ability.create('A01V',"thunderbolt",TARGET_TYPE_UNIT,55,55,55,55)
            set WARRIOR_BATTLE_CRY = Ability.create('A00P',"roar",TARGET_TYPE_NONE,45,45,45,45)
            set WARRIOR_BATTLE_CRY.whichBuff = 'B00E'
            set WARRIOR_CHARGE = Ability.create('A01F',"banish",TARGET_TYPE_UNIT,40,30,0,0)
            set WARRIOR_BLOOD_RAGE = Ability.create('A01W',"defend",TARGET_TYPE_NONE,0,0,0,0)
            
            set WARRIOR.model = gg_unit_E003_0007
            
            set WARRIOR.isHero = true
            
            set WARRIOR.range = Unit.DISTANCE_MELEE
        endmethod
        
    endstruct

endlibrary


I have a bunch of other functions that, when the hero sees a unit (or a bunch of other events), it determines whether he should flee, engage, or avoid that unit. This here is the engage function for the Warrior unit. Basically, he charges units that are out of distance, and actually uses all his abilities correctly. :p
 

Oninuva

You can change this now in User CP.
Reaction score
221
I don't believe you can make a AI that will perform as well as top-level players. AIs just lack creativity that players tend to have and even though they can perform build orders, they won't be able to micro or change their plans according to the map, start position, opponent, etc.
 

Slapshot136

Divide et impera
Reaction score
471
I don't believe you can make a AI that will perform as well as top-level players. AIs just lack creativity that players tend to have and even though they can perform build orders, they won't be able to micro or change their plans according to the map, start position, opponent, etc.

deepblue anyone? it's just a matter of time
 

Sevion

The DIY Ninja
Reaction score
424
I don't believe you can make a AI that will perform as well as top-level players. AIs just lack creativity that players tend to have and even though they can perform build orders, they won't be able to micro or change their plans according to the map, start position, opponent, etc.

The only thing that an AI can't do is create new build orders for new maps.

Period. Everything else, it can do. (Including talk, micro, macro, change build orders, be flexible, scout, change plan on map, start position, opponent... Etc).

Bank? Find specific features of each map and store that into a bank to find what map it is. Opponent? Have a skill level monitor and save that to a bank. Start position? Games provide start locations as points. And you can know them (considering you're making a fair AI) because minerals are there (in Melee games).

In short... The only thing an AI CAN'T do is create a NEW plan for a NEW map.
 

Siretu

Starcraft 2 Editor Moderator
Reaction score
293
Why wouldn't you be able to create an AI that works on a new map?

With good coding you should be able to analyze a map and get the strategic positions.

Also, about making new strategies: What's actually new? With some genetic programming the AI would be able to make up new strategies that you never taught it.

Hmm, I wonder if there's a way to increase game speed by 1000x to make genetic programming faster.... interesting...
 

Slapshot136

Divide et impera
Reaction score
471
With some genetic programming the AI would be able to make up new strategies that you never taught it.

now your talking about a "real" AI that is capable of learning.. which I don't think has been created yet, but in any case, would take tons of code, and a long time to "learn" - not something that can be done from ground zero each time you load the map on an average (ok even super-high-end desktop)
 

Sevion

The DIY Ninja
Reaction score
424
The closest thing to creating a learning AI with Starcraft II is to have it have sets of code that it thinks about which to turn in which situation. And in any case scenario, if we have the same situation, he'll do the same thing. He won't create NEW things to do.
 

Arkless

New Member
Reaction score
31
now yer talking about a "real" AI that is capable of learning.. which I don't think has been created yet, but in any case, would take tons of code, and a long time to "learn" - not something that can be done from ground zero each time you load the map on an average (ok even super-high-end desktop)
Well, there are already other games that do stuff like that (there was even an ego-shooter from 1998 wich had an "intelligent" ai).
I don't think creating tactics based on the terrain is too hard, I say a 5 minutes initialization would be more than enough.

It's not hard to find key-positions and an ai can micro the units way better than a player, so I think it would have a HUGE advantage. Even if the ai wasnt as good as the player, micro on every unit in slightly favored positions would make up for it.

The closest thing to creating a learning AI with Starcraft II is to have it have sets of code that it thinks about which to turn in which situation. And in any case scenario, if we have the same situation, he'll do the same thing. He won't create NEW things to do.
If you let 2 ais play vs. each other that would be right. But the player input is somewhat random and never timed exactly the same, so there is an infinite amount of reactions possible (only limited by the opportunities the game offers).
 

Siretu

Starcraft 2 Editor Moderator
Reaction score
293
now your talking about a "real" AI that is capable of learning.. which I don't think has been created yet, but in any case, would take tons of code, and a long time to "learn" - not something that can be done from ground zero each time you load the map on an average (ok even super-high-end desktop)

What do you mean by a "real" AI? A Strong AI(http://en.wikipedia.org/wiki/Strong_AI)?

You're right about the code part. It would take lots of code.

However the time it would take to "learn" is relative. I know I saw a speed hack for SC2 that increased the game speed to a ridiculous rate. Using that, you would be able to have a program test the map lots of times and save the results and use it for genetic programming(http://en.wikipedia.org/wiki/Genetic_programming)

Thing is, this would not have to be done every time it plays. This is just preliminary to make the AI "learn" SC2. So you get a computer that "knows" SC2, add perfect micro and stuff like that and you got a very good AI.
 

tom_mai78101

The Helper Connoisseur / Ex-MineCraft Host
Staff member
Reaction score
1,632
Last night, I have this vision.

That a pro AI learns how to combat professional human players, with Rock-Paper-Scissors tactics.

If you could do some research on what units are best used against, what units are weak against, what units are good to match up with, what units are not vulnerable under certain conditions, etc., and compare the weakness and strength of each units with either the same or other units.

You'll be able to create an AI that relys on statistical calculations from mere scouting, and make predictions based on the visions the AI had seen with the scouting unit. You'll need to randomize the units in the list of units that are able to counter the units the human player had trained on the field. Make it so that the AI makes a healthy team of units with advantages, with little to no disadvantages.

You'll be able to create an AI that also learns from its ability to counter the unit. If the AI had one army defeating the rest, tell it not to continue using it and go up the food chain. Use the Rock-Paper-Scissor strategy wisely, like how most Japanese video games based their strategies on.

Use as much If-Then-Else as possible. The more, the merrier.

Think of the Yin Yang. Think of the right and wrong. The AI must learn to cope the wild nature of randomness. The AI must use its skills in mathematics to calculate the tides that are coming.

It's probably something even the AI Editor can't do after that.
 

Sevion

The DIY Ninja
Reaction score
424
Perhaps if I still did SC2 Scripting, I would collaborate with someone to bring this forward lol. But that's lots of melee testing etc.
 

Siretu

Starcraft 2 Editor Moderator
Reaction score
293
Yes, it'd be awesome. I might start something like that when/if I get some free time and when I'm not working on any projects.
 

Slapshot136

Divide et impera
Reaction score
471
What do you mean by a "real" AI? A Strong AI(http://en.wikipedia.org/wiki/Strong_AI)?

You're right about the code part. It would take lots of code.

However the time it would take to "learn" is relative.

yes, strong AI then - something that does not yet exist

relative to the time it takes a person to get impatient(even on a fast high-end desktop), it would require a while to analyze a new opponent/new map, even if data for other maps existed within the code

and about the code - would it even fit within the sc2 map limit?
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top