• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Crash] [AI] can't figure out why AI is crashing game and i'm going crazy

Status
Not open for further replies.
Level 18
Joined
Mar 16, 2008
Messages
721
AI keeps crashing map, sometimes 4 mins in, sometimes 1 hour in.

1) I got rid of all the "red" food violations
2) double checked there are no tech violations / made sure everything makes sense on object editor
3) of course object data is up to date
4) i'm 99% sure it's the ai causing the crash because that's the only thing changed recently, and game was performing perfectly before, played dozens of times with human+ai players

if anyone is willing to suggest other possible errors that causes AI to crash, i'd really appreciate that, i'm going crazy. I can't find any good guides for custom ai.

Do conditions matter? i have a ton of conditions but not sure it's helping or bugging it out. when is it appropriate to use a condition in gui ai editor?
 
Last edited:
Level 12
Joined
Feb 5, 2018
Messages
521
One AI crash I know for sure exists and is pretty hard to work around is this; The AI tries to build a structure to a place where it cannot be built. This unfortunately creates an infinite loop and crashes the game, since the AI literally gives the same 10,000 orders in 0,1 second.

It could be that some colors for the AI are bad starting bases, therefore the game crashes in 4 minutes. And sometimes maybe they try to build something later in some expasion base or so? So it crashes way later.

It could maybe also be some other wierd order loop, but that is unlikely.

Maybe you added some decorations or something to the bases and now the AI can't place all buildings they want.
 
Level 18
Joined
Mar 16, 2008
Messages
721
I sincerely appreciate the tip. I flattened all terrain and removed a lot of the doodads but it still seems to crash, idk how far in but i just let it run before i went to sleep. I even turned off some suspect triggers for that test.

Seems like no one really understands gui ai editor, and the few people who are talented enough to just say "screw this" and write a totally custom script without the gui ai editor.

It must be something in the priority list. I think it might be a triple condition I have like (x and (y and z)) for a 3 tiered building? maybe the resource mining condition of all workers not attacking farm lumber? I don't know.

JASS:
    if (( ( GetUnitCount( 'h00A' ) == 0 ) and ( ( GetUnitCount( 'h00B' ) == 0 ) and ( GetUnitCount( 'h00K' ) == 0 ) ) )) then
        call SetBuildAll( BUILD_UNIT, 1, 'hbar', -1 )
    endif

I'm fairly certain the crash cause is in this part of the AI script, because I removed it and the game seems to run for ever. Not sure exactly why. I don't see a tech tree impossibility but i'm carefully looking it over:
JASS:
if (( GetUnitCountDone( 'hbla' ) >= 1 )) then
        call SetBuildAll( BUILD_UPGRADE, 16, 'Rhme', -1 )
    endif
    call SetBuildAll( BUILD_UNIT, 1, 'h035', -1 )
    if (( GetUnitCountDone( 'hbla' ) >= 1 )) then
        call SetBuildAll( BUILD_UPGRADE, 17, 'Rhme', -1 )
    endif
    call SetBuildAll( BUILD_UNIT, 1, 'h03H', -1 )
    call SetBuildAll( BUILD_UNIT, 4, 'h034', -1 )
    call SetBuildAll( BUILD_UNIT, 5, 'h034', -1 )
    if (( GetUnitCountDone( 'h03H' ) >= 1 )) then
        call SetBuildAll( BUILD_UNIT, 1, 'h032', -1 )
        call SetBuildAll( BUILD_UNIT, 1, 'h02X', -1 )
        call SetBuildAll( BUILD_UNIT, 2, 'h02X', -1 )
        call SetBuildAll( BUILD_UNIT, 3, 'h02X', -1 )
        call SetBuildAll( BUILD_UNIT, 4, 'h02X', -1 )
    endif
    if (( GetUnitCountDone( 'hbla' ) >= 1 )) then
        call SetBuildAll( BUILD_UPGRADE, 18, 'Rhme', -1 )
        call SetBuildAll( BUILD_UPGRADE, 19, 'Rhme', -1 )
        call SetBuildAll( BUILD_UPGRADE, 20, 'Rhme', -1 )
    endif
    if (( GetUnitCountDone( 'hlum' ) >= 1 )) then
        call SetBuildAll( BUILD_UPGRADE, 3, 'Rhac', -1 )
    endif
    if (( GetUpgradeLevel( 'Rhme' ) >= 20 )) then
        call SetBuildAll( BUILD_UPGRADE, 1, 'R008', -1 )
    endif
    call SetBuildAll( BUILD_UNIT, 1, 'h030', -1 )
    call SetBuildAll( BUILD_UNIT, 2, 'h030', -1 )
    call SetBuildAll( BUILD_UNIT, 3, 'h030', -1 )
    call SetBuildAll( BUILD_UNIT, 4, 'h030', -1 )
    if (( GetUnitCountDone( 'h03H' ) >= 1 )) then
        call SetBuildAll( BUILD_UNIT, 2, 'h032', -1 )
        call SetBuildAll( BUILD_UNIT, 3, 'h032', -1 )
        call SetBuildAll( BUILD_UNIT, 4, 'h032', -1 )
        call SetBuildAll( BUILD_UNIT, 5, 'h032', -1 )
    endif
    if (( GetUpgradeLevel( 'Rhme' ) >= 20 )) then
        call SetBuildAll( BUILD_UPGRADE, 2, 'R008', -1 )
    endif
    if (( GetUnitCountDone( 'h03H' ) >= 1 )) then
        call SetBuildAll( BUILD_UNIT, 6, 'h032', -1 )
        call SetBuildAll( BUILD_UNIT, 7, 'h032', -1 )
        call SetBuildAll( BUILD_UNIT, 8, 'h032', -1 )
        call SetBuildAll( BUILD_UNIT, 9, 'h032', -1 )
    endif
    if (( GetUnitCountDone( 'h00K' ) >= 1 )) then
        call SetBuildAll( BUILD_UNIT, 5, 'h00L', -1 )
        call SetBuildAll( BUILD_UNIT, 6, 'h00L', -1 )
        call SetBuildAll( BUILD_UNIT, 7, 'h00L', -1 )
    endif
    if (( GetUpgradeLevel( 'Rhme' ) == 20 )) then
        call BuildExpansion( 'htow', 'htow' )
        call BuildExpansion( 'htow', 'htow' )
        call BuildExpansion( 'htow', 'htow' )
        call BuildExpansion( 'htow', 'htow' )
    endif
endfunction
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,511
Not sure, I've never messed with AI before nor do I know any people that have, but I see a bunch of repetition in that code.

For example there's 3 uses of this line:
vJASS:
if (( GetUnitCountDone( 'hbla' ) >= 1 )) then
Which I imagine could be combined together. Also, there's no need for the double parenthesis (( )).

Are you sure you've looked over it thoroughly enough? Maybe you meant to use == instead of >= somewhere?

Again, I've never messed with this stuff before so I can only guess. Anyway, here's the combined code:
vJASS:
    if ( GetUnitCountDone( 'hbla' ) >= 1 ) then
        call SetBuildAll( BUILD_UPGRADE, 16, 'Rhme', -1 )
        call SetBuildAll( BUILD_UPGRADE, 17, 'Rhme', -1 )
        call SetBuildAll( BUILD_UPGRADE, 18, 'Rhme', -1 )
        call SetBuildAll( BUILD_UPGRADE, 19, 'Rhme', -1 )
        call SetBuildAll( BUILD_UPGRADE, 20, 'Rhme', -1 )
    endif
    call SetBuildAll( BUILD_UNIT, 1, 'h035', -1 )
    call SetBuildAll( BUILD_UNIT, 1, 'h03H', -1 )
    call SetBuildAll( BUILD_UNIT, 4, 'h034', -1 )
    call SetBuildAll( BUILD_UNIT, 5, 'h034', -1 )
    if ( GetUnitCountDone( 'h03H' ) >= 1 ) then
        call SetBuildAll( BUILD_UNIT, 1, 'h032', -1 )
        call SetBuildAll( BUILD_UNIT, 1, 'h02X', -1 )
        call SetBuildAll( BUILD_UNIT, 2, 'h02X', -1 )
        call SetBuildAll( BUILD_UNIT, 3, 'h02X', -1 )
        call SetBuildAll( BUILD_UNIT, 4, 'h02X', -1 )
        call SetBuildAll( BUILD_UNIT, 2, 'h032', -1 )
        call SetBuildAll( BUILD_UNIT, 3, 'h032', -1 )
        call SetBuildAll( BUILD_UNIT, 4, 'h032', -1 )
        call SetBuildAll( BUILD_UNIT, 5, 'h032', -1 )
        call SetBuildAll( BUILD_UNIT, 6, 'h032', -1 )
        call SetBuildAll( BUILD_UNIT, 7, 'h032', -1 )
        call SetBuildAll( BUILD_UNIT, 8, 'h032', -1 )
        call SetBuildAll( BUILD_UNIT, 9, 'h032', -1 )
    endif
    if ( GetUnitCountDone( 'hlum' ) >= 1 ) then
        call SetBuildAll( BUILD_UPGRADE, 3, 'Rhac', -1 )
    endif
    if ( GetUpgradeLevel( 'Rhme' ) >= 20 ) then
        call SetBuildAll( BUILD_UPGRADE, 1, 'R008', -1 )
        call SetBuildAll( BUILD_UPGRADE, 2, 'R008', -1 )
    endif
    call SetBuildAll( BUILD_UNIT, 1, 'h030', -1 )
    call SetBuildAll( BUILD_UNIT, 2, 'h030', -1 )
    call SetBuildAll( BUILD_UNIT, 3, 'h030', -1 )
    call SetBuildAll( BUILD_UNIT, 4, 'h030', -1 )
    if ( GetUnitCountDone( 'h00K' ) >= 1 ) then
        call SetBuildAll( BUILD_UNIT, 5, 'h00L', -1 )
        call SetBuildAll( BUILD_UNIT, 6, 'h00L', -1 )
        call SetBuildAll( BUILD_UNIT, 7, 'h00L', -1 )
    endif
    if ( GetUpgradeLevel( 'Rhme' ) == 20 ) then
        call BuildExpansion( 'htow', 'htow' )
        call BuildExpansion( 'htow', 'htow' )
        call BuildExpansion( 'htow', 'htow' )
        call BuildExpansion( 'htow', 'htow' )
    endif
endfunction
You can always debug it through trial and error. Comment out one thing at a time and test the map.
 
Last edited:
Status
Not open for further replies.
Top