HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Can someone help me improve my AI? Any advice would help.

07-31-2006, 07:56 AM#1
Sardius
My AI seems to be working alright for the most part, and although it pretty much follow the official campaign AI scripts almost exactly, I've noticed a few problems randomly occuring in attack waves that I'd like to correct or improve on and would appreciate any help.

1.) Sometimes the attack waves seems to split up and the computer carelessly sends that attack wave a few units at a time, until that attack force is wiped out.foolishly This doesn't happen all the time, but it happens frequently enough.

2.) Sometimes they just don't even build and send a unit that is suppose to be part of the called attack wave, and food or resources is not an issue.

My AI is activated like this in my map.

Trigger:
AI - Start campaign AI script for Player 6 (Orange): 01_Orange1.ai
AI - Send Player 6 (Orange) the AI Command (0, 0)

This is the same way the campaign levels activate their AI scripts, although I have absolutly no idea what the Send Player Command 0, 0 does.

Below is a small portion of my AI script

Collapse JASS:
   //*** WAVE 3 ***
    call InitAssaultGroup()
    call CampaignAttackerEx( 3,3,3, RAIDER            )
    call CampaignAttackerEx( 3,3,3, CATAPULT    )
    call CampaignAttackerEx( 3,3,3, WYVERN    )
    call SuicideOnPlayerEx(M5,M4,M3,user)

    //*** WAVE 4 ***
    call InitAssaultGroup()
    call CampaignAttackerEx( 2,2,2, WITCH_DOCTOR            )
    call CampaignAttackerEx( 2,2,2, RAIDER        )
    call CampaignAttackerEx( 2,2,2, HEAD_HUNTER            )
    call CampaignAttackerEx( 1,1,1, 'Opgh'        )
    call SuicideOnPlayerEx(M6,M5,M4,user)

    //*** WAVE 5 ***
    call InitAssaultGroup()
    call CampaignAttackerEx( 8,8,8, WYVERN            )
    call CampaignAttackerEx( 2,2,2, TAUREN            )
    call CampaignAttackerEx( 4,4,4, SAPPER            )
    call SuicideOnPlayerEx(M6,M5,M4,user) 

For example, the last time I played my map. Wave 4 assault went flawlessly, yet wave 3 split up, raiders came first, a minute later the wyverns came, then finally the catapults... Wave 5 was the most messed up... All 8 wyverns came individually over about a minute long period, then the Tauren's came one at a time... The Sapper's never showed up in this wave at all! But orcish bases can build sappers in my map and they do use the constant variable "Sapper" Plus I have seen them send sappers in this very same attack wave before and in other waves throughout my map.

Can anyone help me with any added commands, removals or adjustments to my script that would prevent this problems from occuring?
08-02-2006, 06:53 AM#2
Sardius
Hello, anyone? I'm sure someones gotta know more about AI then I do considering I hardly know anything about it.
08-02-2006, 05:25 PM#3
Alevice
Considering most fo your AI related threads I think there are very few people that focus on AI. :P
08-02-2006, 06:02 PM#4
Sardius
But there are a lot of custom campaigns out there and that a few that are being worked on, I would imagine a lot of them would use cusom AI scripts.
08-02-2006, 06:03 PM#5
Rising_Dusk
I would imagine people just trigger it using IssueImmediateOrder()s to groups and such.
I know I would.
08-02-2006, 06:57 PM#6
moyack
If you put the whole AI code, we could help you a bit.

BTW, This issue usually happens because the AI player don't have enough resources.
Just for testing, set at map initialization a lot resources for the AI and check how does it behave.
08-03-2006, 01:21 AM#7
Sardius
Well I've made sure they have a lot of resources for sure, and much like the official campaign, they get more when they run low through triggers, as it is campaign AI...

In terms of the full code, in terms of starting my script I use this.

Trigger:
AI - Start campaign AI script for Player 6 (Orange): 01_Orange1.ai
AI - Send Player 6 (Orange) the AI Command (0, 0)

My ENTIRE AI script if you think it'll help track down my issues looks like this, but is their another command I should be using to call attackers, and initiate an assault on the player? Or anything you can see in here that would explain why sometimes they exlude units from certain attack waves or why sometimes they send only a few units of the attack wave at a time?

Collapse JASS:
 //============================================================================
//  Arimyth 01 -- Orange Player -- AI Script
//============================================================================
globals
    player user = Player(1)
endglobals

//============================================================================
//  main
//============================================================================
function main takes nothing returns nothing
    call CampaignAI(BURROW,null)
    call SetReplacements(2,3,4)
      call SetSmartArtillery(true)
      set campaign_wood_peons = 2
      set campaign_gold_peons = 2
         
    call SetBuildUnitEx    ( 1,1,1, GREAT_HALL            )
    call SetBuildUnit    ( 3, PEON                    )    
    call SetBuildUnitEx    ( 2,2,2, ORC_BARRACKS        )
    call SetBuildUnitEx    ( 1,1,1, FORGE                )
    call SetBuildUnitEx    ( 1,1,1, TOTEM                )
    call SetBuildUnitEx    ( 1,1,1, STRONGHOLD            )
    call SetBuildUnitEx    ( 1,1,1, ORC_ALTAR            )
    call SetBuildUnitEx    ( 1,1,1, LODGE                )
    call SetBuildUnitEx    ( 2,2,2, BESTIARY            )
    call SetBuildUnitEx    ( 1,1,1, FORTRESS            )

    call CampaignDefenderEx( 1,1,1, 'Opgh'    )
      call CampaignDefenderEx( 1,1,1, 'O00D'    )   
      
    call WaitForSignal()

    //*** WAVE 1 ***
    call InitAssaultGroup()
    call CampaignAttackerEx( 2,2,2, GRUNT            )
    call CampaignAttackerEx( 2,2,2, RAIDER        )
    call CampaignAttackerEx( 2,2,2, HEAD_HUNTER      )
    call SuicideOnPlayerEx(M4,M3,M2,user)

    //*** WAVE 2 ***
    call InitAssaultGroup()
    call CampaignAttackerEx( 2,2,2, SHAMAN            ) 
    call CampaignAttackerEx( 4,4,4, GRUNT                  )
    call CampaignAttackerEx( 1,1,1, KODO_BEAST              )
    call SuicideOnPlayerEx(M5,M4,M3,user)

    //*** WAVE 3 ***
    call InitAssaultGroup()
    call CampaignAttackerEx( 3,3,3, RAIDER            )
    call CampaignAttackerEx( 3,3,3, CATAPULT    )
    call CampaignAttackerEx( 3,3,3, WYVERN    )
    call SuicideOnPlayerEx(M5,M4,M3,user)

    //*** WAVE 4 ***
    call InitAssaultGroup()
    call CampaignAttackerEx( 2,2,2, WITCH_DOCTOR            )
    call CampaignAttackerEx( 2,2,2, RAIDER        )
    call CampaignAttackerEx( 2,2,2, HEAD_HUNTER            )
    call CampaignAttackerEx( 1,1,1, 'Opgh'        )
    call SuicideOnPlayerEx(M6,M5,M4,user)

    //*** WAVE 5 ***
    call InitAssaultGroup()
    call CampaignAttackerEx( 8,8,8, WYVERN            )
    call CampaignAttackerEx( 2,2,2, TAUREN            )
    call CampaignAttackerEx( 4,4,4, SAPPER            )
    call SuicideOnPlayerEx(M6,M5,M4,user)

    //*** WAVE 6 ***
    call InitAssaultGroup()
    call CampaignAttackerEx( 1,1,1, WITCH_DOCTOR            )
    call CampaignAttackerEx( 1,1,1, SHAMAN        )
    call CampaignAttackerEx( 4,4,4, CATAPULT            )
    call CampaignAttackerEx( 1,1,1, 'O00D'        )
    call CampaignAttackerEx( 2,2,2, GRUNT                  )
    call CampaignAttackerEx( 1,1,1, KODO_BEAST              )
    call SuicideOnPlayerEx(M6,M5,M4,user)    

    //*** WAVE 7 ***
    call InitAssaultGroup()
    call CampaignAttackerEx( 4,4,4, TAUREN            )
    call CampaignAttackerEx( 1,1,1, SHAMAN        )
    call CampaignAttackerEx( 1,1,1, WITCH_DOCTOR            )
    call CampaignAttackerEx( 4,4,4, SAPPER        )
    call CampaignAttackerEx( 2,2,2, CATAPULT                  )
    call CampaignAttackerEx( 1,1,1, KODO_BEAST              )
    call SuicideOnPlayerEx(M6,M5,M4,user)    

    //*** WAVE 8 ***
    call InitAssaultGroup()
    call CampaignAttackerEx( 4,4,4, WYVERN            )
    call CampaignAttackerEx( 2,2,2, HEAD_HUNTER        )
    call CampaignAttackerEx( 2,2,2, SHAMAN        )
    call CampaignAttackerEx( 2,2,2, WITCH_DOCTOR    )
    call CampaignAttackerEx( 1,1,1, KODO_BEAST              )
    call CampaignAttackerEx( 1,1,1, 'Opgh'        )
    call SuicideOnPlayerEx(M7,M6,M5,user)

    //*** WAVE 9 ***
    call InitAssaultGroup()
    call CampaignAttackerEx( 3,3,3, GRUNT            )
    call CampaignAttackerEx( 3,3,3, TAUREN            )
    call CampaignAttackerEx( 1,1,1, KODO_BEAST              )
    call CampaignAttackerEx( 3,3,3, HEAD_HUNTER        )
    call CampaignAttackerEx( 3,3,3, RAIDER            )
    call CampaignAttackerEx( 3,3,3, CATAPULT        )
    call CampaignAttackerEx( 1,1,1, 'O00D'        )
    call SuicideOnPlayerEx(M7,M6,M5,user)

    //*** WAVE 10 ***
    call InitAssaultGroup()
    call CampaignAttackerEx( 6,6,6, HEAD_HUNTER            )
    call CampaignAttackerEx( 6,6,6, RAIDER        )
    call CampaignAttackerEx( 2,2,2, SHAMAN            )
    call CampaignAttackerEx( 2,2,2, WITCH_DOCTOR    )
    call CampaignAttackerEx( 1,1,1, KODO_BEAST              )
    call CampaignAttackerEx( 1,1,1, 'Opgh'        )
    call CampaignAttackerEx( 3,3,3, SAPPER        )
    call SuicideOnPlayerEx(M7,M6,M5,user)

    //*** WAVE 11 ***
    call InitAssaultGroup()
    call CampaignAttackerEx( 6,6,6, CATAPULT            )
    call CampaignAttackerEx( 6,6,6, SAPPER        )
    call CampaignAttackerEx( 6,6,6, WYVERN            )
    call CampaignAttackerEx( 3,3,3, KODO_BEAST              )
    call CampaignAttackerEx( 1,1,1, 'O00D'        )
    call SuicideOnPlayerEx(M7,M6,M5,user)

    call SetBuildUpgrEx( 1,1,1, UPG_ORC_BERSERKER        )

    loop
        //*** WAVE 12 ***
        call InitAssaultGroup()
        call CampaignAttackerEx( 6,6,6, BATRIDER            )
        call CampaignAttackerEx( 4,4,4, BERSERKER        )
        call CampaignAttackerEx( 2,2,2, SHAMAN        )
            call CampaignAttackerEx( 2,2,2, WITCH_DOCTOR    )
        call CampaignAttackerEx( 2,2,2, KODO_BEAST              )
            call CampaignAttackerEx( 1,1,1, 'Opgh'        )
        call SuicideOnPlayerEx(M8,M7,M6,user)

        //*** WAVE 13 ***
        call InitAssaultGroup()
        call CampaignAttackerEx( 4,4,4, GRUNT            )
        call CampaignAttackerEx( 2,2,2, TAUREN            )
            call CampaignAttackerEx( 1,1,1, KODO_BEAST              )
            call CampaignAttackerEx( 2,2,2, SPIRIT_WALKER        )
        call CampaignAttackerEx( 1,1,1, SHAMAN            )
        call CampaignAttackerEx( 4,4,4, RAIDER            )
            call CampaignAttackerEx( 3,3,3, CATAPULT        )
        call CampaignAttackerEx( 1,1,1, 'O00D'        )
            call SuicideOnPlayerEx(M8,M7,M6,user)

        //*** WAVE 14 ***
        call InitAssaultGroup()
        call CampaignAttackerEx( 8,8,8, BERSERKER            )
        call CampaignAttackerEx( 8,8,8, RAIDER        )
        call CampaignAttackerEx( 1,1,1, SHAMAN            )
        call CampaignAttackerEx( 1,1,1, WITCH_DOCTOR    )
        call CampaignAttackerEx( 2,2,2, KODO_BEAST              )
            call CampaignAttackerEx( 1,1,1, 'Opgh'        )
        call CampaignAttackerEx( 4,4,4, SAPPER        )
            call SuicideOnPlayerEx(M8,M7,M6,user)

            //*** WAVE 15 ***
        call InitAssaultGroup()
        call CampaignAttackerEx( 6,6,6, CATAPULT            )
        call CampaignAttackerEx( 8,8,8, SAPPER        )
            call CampaignAttackerEx( 4,4,4, TAUREN            )
        call CampaignAttackerEx( 4,4,4, BATRIDER            )
        call CampaignAttackerEx( 2,2,2, KODO_BEAST              )
            call CampaignAttackerEx( 1,1,1, 'O00D'        )
            call SuicideOnPlayerEx(M8,M7,M6,user)

            //*** WAVE 16 ***
        call InitAssaultGroup()
        call CampaignAttackerEx( 4,4,4, SPIRIT_WALKER            )
        call CampaignAttackerEx( 1,1,1, WITCH_DOCTOR        )
        call CampaignAttackerEx( 1,1,1, SHAMAN            )
        call CampaignAttackerEx( 2,2,2, KODO_BEAST              )
            call CampaignAttackerEx( 1,1,1, 'O00D'        )
            call CampaignAttackerEx( 1,1,1, 'Opgh'        )
            call SuicideOnPlayerEx(M8,M7,M6,user)

            //*** WAVE 17 ***
        call InitAssaultGroup()
        call CampaignAttackerEx( 4,4,4, BATRIDER            )
        call CampaignAttackerEx( 3,3,3, SPIRIT_WALKER        )
        call CampaignAttackerEx( 4,4,4, BERSERKER                )
        call CampaignAttackerEx( 2,2,2, KODO_BEAST              )
            call CampaignAttackerEx( 4,4,4, SAPPER        )
            call CampaignAttackerEx( 3,3,3, CATAPULT        )
            call CampaignAttackerEx( 3,3,3, TAUREN            )
            call CampaignAttackerEx( 3,3,3, WYVERN            )
            call SuicideOnPlayerEx(M8,M7,M6,user)

    endloop
endfunction 
08-05-2006, 05:31 PM#8
Sardius
I guess it doesn't help...
08-14-2006, 04:19 PM#9
Sardius
babump
08-14-2006, 04:29 PM#10
Vexorian
What happened is that most of the people that use ai scripts left, and the remanents prefer to use the map's script directly for the AI instead of actual ai scripts.
08-20-2006, 06:12 PM#11
Sardius
So there is no one here then that can help me improve my script.