Rocky II Zerg and Protoss AI (Updated 02/02/12)

Help - Resources - AI Scripting - Grafting - Plugins - Modding Projects
User avatar
JH24
Posts: 323
Joined: Sat Mar 14, 2009 6:25 pm

Rocky II Zerg and Protoss AI (Updated 02/02/12)

Postby JH24 » Tue Apr 07, 2009 9:07 pm

Rocky II Zerg and Protoss AI

You'll need BWAIlauncher to play against this AI. You can find the BWAIlauncher in this topic:
index.php?showtopic=452

The previous version has been re-uploaded in a Winrar file further down this post.

Rocky II Zerg non-cheating AI: [attachment=2996:Rocky II Zerg v2.7a non-cheating.txt]
Rocky II Zerg non-cheating low-tech AI (It won't go past Lair): [attachment=2995:Rocky II Zerg v2.7a non-cheating low-tech.txt]

To play, right click the file above and save it to your BWAILauncherPackages\01) Entropy (Non-Cheating)/ (Zerg) directory.

Rocky II Zerg cheating AI: [attachment=2990:Rocky II Zerg v2.7 cheating.txt]

Rocky II Zerg cheating low-tech AI (It won't go past Lair): [attachment=2992:Rocky II Zerg v2.7 cheating low-tech.txt]

To play, right click the file above and save it to your /BWAILauncher/Packages/03) Racine's Rebels (Pro $)/ (Zerg) directory.

===

Rocky II Protoss non-cheating AI: [attachment=2986:Rocky II Protoss v2.6 non-cheating.txt]

To play, right click the file above and save it to your BWAILauncherPackages\01) Entropy (Non-Cheating)/ (Protoss) directory.

Rocky II Protoss cheating AI: [attachment=2991:Rocky II Protoss v2.6 cheating.txt]

To play, right click the file above and save it to your /BWAILauncher/Packages/03) Racine's Rebels (Pro $)/ (Protoss) directory.

===

Previous Protoss/Zerg AI version: [attachment=2985:Rocky II older Protoss and Zerg AI scripts..rar]

===

AI description:

The "vanilla" AI's only make use of the original units in Starcraft.
The "expansion" AI's also make use of the units available in Brood War.


This AI is designed to be stronger during mid- and lategame scenario's. It does not perform early rushes and it's weaker in the early game. Generally, the AI needs a preparation time of around 7-10 minutes but will defend against earlier attacks. It focuses on building large armies, fighting huge battles, and producing new units non-stop or with as few breaks as possible.

The cheating Gold AI's receive bonus resources but will still try to play "fair". The AI's won't build for example 12 gateways or hatcheries in the first minute or anytime later in the game. They'll follow the original non-cheating script but generally their armies will be much larger then with the non-cheating AI's. They will also upgrade and tech more aggressively.

The bonus resources for the cheating AI's are temporary, after around 30 minutes these AI's won't receive any free resources anymore. It's still possible to drain a cheating AI of resources.


Special thanks to:
Archon_Wing- For all your support and awesome advice, your awesome AI FAQ on this site, and for the original attack structure for Zerg/Protoss.
Bajadulce- For all your help and valuable advice, as well as creating/maintaining this awesome site.
Myk and PandaBB- For all your helpful support and feedback, as well as creating awesome Zerg AI's of which I really learned a lot from.
Bmnbmn, Equalizer, Faded_Sentry, Symmetry, X_Of_Life and HasherL- For your great advice, support and comments.
Iskatumesk- For sharing all your knowledge of AI scripting as well as for your great advice.
poiuy_qwert- For the creation of PYAI, a great program which really made AI scripting a lot of fun for me. And for BWAI Launcher, that has made testing and editing AI's so much more fun and easier!

Everyone that downloaded this file.
If I have forgotten to mention someone in the credits, my sincere apologies. Please let me know and I'll add you immediately.


Also, you have my permission to continue working on these scripts, modifying them in any way or using them or part of them as base for other AI's.
User avatar
Archon_Wing
Posts: 903
Joined: Wed Jul 25, 2007 11:22 pm

Postby Archon_Wing » Tue Apr 07, 2009 10:22 pm

Sup, I'll probaly play against your AI when I feel like playing sc again, but I'll probaly run it against some AI vs Ai reps to see how it does. You should post the scripts in spoiler form, asc3 files or as text files so we can easily read what you coded.

It's a very simple, basic AI and currently it's not good at all
Don't mislead people like that lol. The hardcoded problems prevent a non-cheating ai from being a good 1v1 opponent, but 1v2 it can be pretty difficult, especially pvp and tvp.

2. Several random choices are put into the script for the AI. Currently mainly regarding attacking. In some games the AI will leave you alone for a while, while in other games the AI will attack and rush you throughout the game. Usually the result will be something inbetween.
This is a good idea, helps prevent predictability.

1. Currently the Terran AI is the weakest of the three AI's. I'm not very good with Terrans at all, so I had some difficulty balancing the builds and units. My sincere thanks to Archon_Wing for his very valuable advice. You really helped me to make the Terran AI more balanced.
Terran's simply the weakest AI race for a few reasons because:

- The unfortunate bug where they don't continue buildings if destroyed. If Firegraft gets updated some day, maybe we can put that in without requiring people to switch versions , though it'd really suck of Blizzard updated again lol. I generally hate having to switch versions of sc, as it is quite a hassle for people that download my stuff. Most people aren't going to bother with anything besides unzipping the file and double clicking on it and even that proves to be too hard for some people. ;)

- Terran units are the weakest without a good micro. You can never defeat someone else by attack moving your army because 3 lurkers could mean the end. And the comp can't even attack-move it seems
- Terran building is the most complex, with addons and stupid crap like that. Their buildings are also the largest so you really can't fit too many, either
- Related to the bad micro, terrans are naturally the most vulnerable to rushes. They also don't repair effectively so defense is pretty weak.
- Terrans have finicky unit choices which vary widely between matchups. Unlike Protoss, they can't just come up with a general purpose army. M+M are great against zerg but horrible against other terran.
- Terrans are the hardest race for beginners to learn because of most of the above (it's much easier to learn a 5 pool or zealot rush than it is to learn how to hold one off), and these problems are made worse with AI.
- On the other hand, zerg does seem to break for no apparent reason at times, so it's not all bad. ;)

2. The Terran AI is also the slowest of the three AI's. yet I don't really know why. However, it does seem when it has crossed some 'invisible' line within the script, it goes into overdrive and becomes considerably more difficult.

3. For some strange reason, the Terran AI has the tendency to lock up. But strangely only on random moments, I'm not sure what's causing this. I play the coming days more against this script and try to find out if I can localize the problem. Yet, I've had several games on different maps were the AI would perform perfectly.
I really have no idea why it slows down or randomly locks; happens with mine too. It seems to happen more when it techs even if you place buildings smack in the main thread. Usually I have to baby the terran more until it reaches the final loop than my p/z AI which I only write the early game and let them do whatever. You can try lowering the priority for expansion buildings; that's the only thing i came up with. Or place those structures in multiruns so if building gets interrupted, the rest will still continue. It works about 90% of the time, but the 10% I think I'll just have to lvie with. ;)

You could also try being more stingy with defensebuild commands, since there are really few types of units you wanna build when under attack, such as marines. Take the firebat. It could do:

defensebuild_gg (ground to ground)
defensebuild_ga(ground units attacking your air units)

The firebat only needs defensebuild_gg, because there's no ground unit that attacks air that a firebat would be able to handle anyways. The other duties should be handled to the marines.

In the latest version of my scripts I changed my header to include the commands default_min 0 and defaultbuild_off right after the beginning of my script (after start_town and stuff) Not sure what they do, but the script seems to work better after it. I've read that putting start_campaign before start_town could make it faster, but that did some really odd stuff so I took that off.

4. On some maps, especially with relatively small mains, the AI tends to build itself in. I've already let the AI build several production buildings at expansions, I need to look at this again carefully.
Yes, The AI is terrible at building placement, but often times I fault the map. ;) A lot of Blizzard maps tend to be pretty awful when it comes to balance issues.

Here's the building count I did for mine in the mains. It works ok, but can still get seriously crowded. But hey, if the AI doesn't have space to build depots, it will start making these cool supply depot walls at expansions which prove pretty useful for defense.

Terrans: Buildings are big and bulky, especially with addons so less can be put in a T base
TvZ: 7 barracks, 1 factory with addon, 2 starports with addon
TvP: 6 factories, 2 with addons, 1 starport with addon
TvT: Same as tvp, but 2 more starports. Usually extremely crowded ;)

If you are going to use factories for stuff other than tanks, not having addons for your factories can save lots of space.

Protoss usually do better, but need quite a few pylons and like to randomly trap units
7 gateways, 3 stargates, 1 robotics

Zerg: Unlike the other two races, the Zerg AI actually builds pretty neatly. The overmind apparently has OCD.
(up to) 9 hatcheries, though it rarely gets to this point.

Ok gl with improving your script.
User avatar
JH24
Posts: 323
Joined: Sat Mar 14, 2009 6:25 pm

Postby JH24 » Wed Apr 08, 2009 7:17 pm

I have less time left than I expected, I'll reply in more detail to your post tomorrow, Archon_Wing. If you're interested, I've edited my first post and added the scripts for the three races.

Earlier today, for version 0.3 I tried to experiment a bit by moving the main attacks into a multirun thread with resources_jumps and notown_jumps. If it works, I'll wonder if that will make the AI a bit faster. I must say its really fun experimenting and trying out things like this. :)
User avatar
Archon_Wing
Posts: 903
Joined: Wed Jul 25, 2007 11:22 pm

Postby Archon_Wing » Thu Apr 09, 2009 5:25 am

Here's 2 reps, a zvt and a pvz

ZvT- The terran doesn't seem to go on the offensive much. It does however, produce a lot of tanks and has better antiair You could try m+m and tanks vs zerg only, and m+m into pure mech for the others. May even be a good idea to make the ai pop a few wraiths or valks to use as antiair. Pure mech is fine against zerg though.

PvZ- They defended against the sair harass well enough. The attacks were pretty big but took a while to gather. You might have to bother with a few mutas or lurks and hive units if resources allow. I usually prefer to stick the higher tech stuff in a different thread.

Also it seems the zerg script has too many train commands. Train means "train up to this amount" and usually the comp will rebuild, so too many of the same train commands could slow it down. I like to use the train command to sorta specify what kind of minimum force I'd like.

Another command that would help once you have a large army is
guard_resources zergling

That will send 1 zergling to each resource area. For the other races you would want to use a cheap unit.
User avatar
JH24
Posts: 323
Joined: Sat Mar 14, 2009 6:25 pm

Postby JH24 » Thu Apr 09, 2009 8:19 pm

Terran's simply the weakest AI race for a few reasons because: The unfortunate bug where they don't continue buildings if destroyed. If Firegraft gets updated some day, maybe we can put that in without requiring people to switch versions , though it'd really suck of Blizzard updated again lol. I generally hate having to switch versions of sc, as it is quite a hassle for people that download my stuff. Most people aren't going to bother with anything besides unzipping the file and double clicking on it and even that proves to be too hard for some people.

- Terran units are the weakest without a good micro. You can never defeat someone else by attack moving your army because 3 lurkers could mean the end. And the comp can't even attack-move it seems
- Terran building is the most complex, with addons and stupid crap like that. Their buildings are also the largest so you really can't fit too many, either
- Related to the bad micro, terrans are naturally the most vulnerable to rushes. They also don't repair effectively so defense is pretty weak.
- Terrans have finicky unit choices which vary widely between matchups. Unlike Protoss, they can't just come up with a general purpose army. M+M are great against zerg but horrible against other terran.
- Terrans are the hardest race for beginners to learn because of most of the above (it's much easier to learn a 5 pool or zealot rush than it is to learn how to hold one off), and these problems are made worse with AI.
- On the other hand, zerg does seem to break for no apparent reason at times, so it's not all bad.

Heh, you're entirely right. I think I spend three times as long on the Terran AI as I did on the other two. It gave me problems every time. It wouldn't build the units I wanted for some reason, or it would build units I didn't ask for. For some time it would refuse to build a machine shop, and later on it would refuse to build vultures for example. The funny thing is, I still don't really know how I solved those problems. After a few frustrating hours later it just seemed to work again. Oh, well.

That's also the reason why the Terran AI is currently very passive. I just did't dare to take much risks with it yet. At least it does seem to build all the way now. And that's something I'm very grateful for.


Yes, The AI is terrible at building placement, but often times I fault the map. A lot of Blizzard maps tend to be pretty awful when it comes to balance issues.

Here's the building count I did for mine in the mains. It works ok, but can still get seriously crowded. But hey, if the AI doesn't have space to build depots, it will start making these cool supply depot walls at expansions which prove pretty useful for defense.
Terrans: Buildings are big and bulky, especially with addons so less can be put in a T base
TvZ: 7 barracks, 1 factory with addon, 2 starports with addon
TvP: 6 factories, 2 with addons, 1 starport with addon
TvT: Same as tvp, but 2 more starports. Usually extremely crowded

If you are going to use factories for stuff other than tanks, not having addons for your factories can save lots of space.

Protoss usually do better, but need quite a few pylons and like to randomly trap units
7 gateways, 3 stargates, 1 robotics

Zerg: Unlike the other two races, the Zerg AI actually builds pretty neatly. The overmind apparently has OCD.
(up to) 9 hatcheries, though it rarely gets to this point.



Thanks for sharing your building numbers. At the moment my AI uses a standard opening build order for all races but I hope to change this eventually in future versions. Currently the Terran AI builds 4 factories with shops. (I could perhaps build only three shops), three barracks and one starport. For now it seems to work well but I really want some more variety some day.

Protoss are a problem too, I noticed that if they build up forces early and won't attack much building and base placement are usually somewhat better. I wonder if Creep 4 in the beginning will help with building a base.

Here's 2 reps, a zvt and a pvz

ZvT- The terran doesn't seem to go on the offensive much. It does however, produce a lot of tanks and has better antiair You could try m+m and tanks vs zerg only, and m+m into pure mech for the others. May even be a good idea to make the ai pop a few wraiths or valks to use as antiair. Pure mech is fine against zerg though.

PvZ- They defended against the sair harass well enough. The attacks were pretty big but took a while to gather. You might have to bother with a few mutas or lurks and hive units if resources allow. I usually prefer to stick the higher tech stuff in a different thread.

Also it seems the zerg script has too many train commands. Train means "train up to this amount" and usually the comp will rebuild, so too many of the same train commands could slow it down. I like to use the train command to sorta specify what kind of minimum force I'd like.

Another command that would help once you have a large army is
guard_resources zergling
That will send 1 zergling to each resource area. For the other races you would want to use a cheap unit.

Archon_Wing, thank you so much for the awesome and very valuable replays! They really gave me a lot of information! You're also an amazing player. Your strategies and especially the way you handled the Defilers/Lurkers and High Templars was very, very impressive! I haven't incorporated Templar in my AI yet because I was afraid they would harm my own forces too much, but after seeing you play... You're awesome!

I'll do my best to add more variety to the Terran in future versions. I've also lowered the amount of units for the Zerg attacking forces. Hopefully this way they'll attack more often. I also have some idea's to add other Zerg units in the mix. It's a pity the AI doesn't really try to evade or escape from Psi storms.

I also noticed that I probaby need more drones/scv's/probes for my AI's. I hope I'll be able to one day to move the drone production to a separate thread. I played a game earlier today and I noticed that when I took out a few drones the AI would practically do nothing until they were replaced.

Archon_Wing, I hope you don't mind me asking this question. I've made several changes to the scripts for version 0.3. I don't really know though if these changes are for the better or for the worse. I've tried to put the main attacks in a multirun thread, so it would run independently from the main thread, as well as allowing the AI to keep fighting even when almost all buildings are destroyed. (I'll give you full credit for this because I saw your example in the "How to make a better AI" thread.)

Here is a Protoss script (Can I continue this way or would you say I really need to take a different direction?)

Code: Select all

; ASC3 File generated by ScAIEdit III
;
; Script name : Protoss Expansion Custom Level

script_name Protoss Expansion Custom Level
script_id PMCx

start_town
transports_off
farms_notiming
define_max 80 probe
define_max 100 zealot
define_max 100 dragoon
define_max 4 archon
define_max 6 high_templar
define_max 10 dark_templar
define_max 2 reaver
define_max 4 shuttle
define_max 255 scout
define_max 255 arbiter
define_max 255 corsair
define_max 6 carrier

build 1 nexus 150
wait_build 1 nexus
build 5 probe 80
wait_buildstart 5 probe
build 6 probe 80
wait_buildstart 6 probe
build 7 probe 80
wait_buildstart 7 probe
build 1 pylon 80
wait_buildstart 1 pylon
build 8 probe 80
wait_buildstart 8 probe
wait_build 1 pylon
build 1 gateway 80
wait_buildstart 1 gateway
wait_build 1 gateway
train 1 zealot
defensebuild_gg 1 zealot
defenseuse_gg 1 zealot
defensebuild_ga 1 zealot
defenseuse_ga 1 zealot
defensebuild_gg 1 dragoon
defenseuse_gg 1 dragoon
defensebuild_ga 1 dragoon
defenseuse_ga 1 dragoon
defensebuild_ag 1 dragoon
defenseuse_ag 1 dragoon
defensebuild_aa 1 dragoon
defenseuse_aa 1 dragoon
build 9 probe 80
wait_buildstart 9 probe
build 10 probe 80
wait_buildstart 10 probe
build 11 probe 80
wait_buildstart 11 probe
build 2 pylon 80
wait_buildstart 2 pylon
attack_add 2 zealot
build 2 gateway 80
wait_buildstart 2 gateway
build 2 pylon 80
wait_buildstart 2 pylon

farms_timing

build 12 probe 80
wait_buildstart 12 probe
attack_add 4 zealot
build 14 probe 80
wait_buildstart 14 probe

expand 1 block1early
multirun expand

random_jump 63 skiprush
send_suicide 0

wait 100

:skiprush
wait 10

build 16 probe 80
wait_buildstart 16 probe
build 1 assimilator 80
build 3 gateway 80
wait_buildstart 3 gateway
attack_add 8 zealot
random_jump 125 skiprush1
send_suicide 0

wait 100

:skiprush1

build 18 probe 80
wait_buildstart 18 probe
build 20 probe 80
wait_buildstart 20 probe
wait 10

build 4 gateway 80
wait_buildstart 4 gateway
build 1 forge 70
wait_buildstart 1 forge
build 1 cybernetics_core 70
wait_buildstart 1 cybernetics_core
attack_add 5 zealot

multirun block2
multirun block3
wait_build 1 cybernetics_core
attack_add 4 dragoon
random_jump 125 skiprush2
attack_prepare
wait 400

attack_do
attack_clear
clear_combatdata
wait 50

:skiprush2
wait 1

build 1 citadel_of_adun 80
wait 10

attack_add 8 zealot

multirun block4
multirun block5

build 21 probe 80
wait_buildstart 21 probe
build 22 probe 80
wait_buildstart 22 probe
attack_add 9 dragoon

check_transports

build 1 robotics_facility 80
wait_buildstart 1 robotics_facility

defensebuild_gg 1 reaver
defenseuse_gg 1 reaver
defensebuild_ga 1 reaver
defenseuse_ga 1 reaver

wait_build 1 robotics_facility
build 1 observatory 80
wait_buildstart 1 observatory
wait 10

multirun block6
wait 1

attack_add 3 zealot
attack_add 2 dragoon
random_jump 125 skiprush3
attack_prepare
wait 450

attack_do
attack_clear
clear_combatdata
wait 50

:skiprush3
wait 1

build 5 gateway 80
wait_buildstart 5 gateway
wait 10

build 1 robotics_support_bay 60
multirun shuttle

attack_add 6 zealot
attack_add 6 dragoon

:block8
wait 100

defensebuild_gg 1 archon
defenseuse_gg 1 archon
defensebuild_ga 1 archon
defenseuse_ga 1 archon
defensebuild_ag 1 archon
defenseuse_ag 1 archon
defensebuild_aa 1 archon
defenseuse_aa 1 archon
build 1 templar_archives 80
wait_buildstart 1 templar_archives
build 1 stargate 80
wait_buildstart 1 stargate
build 1 fleet_beacon 60
wait_buildstart 1 fleet_beacon
defensebuild_gg 1 carrier
defenseuse_gg 1 carrier
defensebuild_ga 1 carrier
defenseuse_ga 1 carrier
defensebuild_ag 1 carrier
defenseuse_ag 1 carrier
defensebuild_aa 1 carrier
defenseuse_aa 1 carrier
build 2 stargate 80
wait_buildstart 2 stargate
multirun airupgrade1
multirun carrierupgrade
wait 100

attack_add 5 zealot
attack_add 5 dragoon
attack_add 2 archon
attack_add 2 carrier
random_jump 125 skiprush4
attack_prepare
wait 450

attack_do
attack_clear
clear_combatdata
wait 50

:skiprush4
wait 10

race_jump Terranattack Zergattack Protossattack

:Terranattack
wait 1
multirun attackT
wait 1
goto buildcontinue

:Zergattack
wait 1
multirun attackZ
wait 1
goto buildcontinue

:Protossattack
wait 1
multirun attackP
wait 1
goto buildcontinue
stop

:buildcontinue
wait 100
stop

:block3
wait 500
wait_build 1 forge
wait 50
upgrade 1 p_ground_weapon 15
wait 4500

upgrade 1 p_armor 10
wait 4500

upgrade 1 p_plasma_shield 9
wait 4500

:level2
wait 100

notowns_jump templar_archives level2
wait 50

upgrade 2 p_ground_weapon 7
wait 4500

upgrade 2 p_armor 5
wait 4500

upgrade 2 p_plasma_shield 2
wait 4500

:level3
wait 100

notowns_jump fleet_beacon level3
wait 100

upgrade 3 p_ground_weapon 2
wait 6500

upgrade 3 p_armor 2
wait 6500

upgrade 3 p_plasma_shield 3
wait 6500

stop

:block1
wait 100

start_town
build 1 nexus 150
wait_buildstart 1 nexus
build 1 pylon 80
wait_buildstart 1 pylon
wait_build 1 nexus
multirun block13
multirun expansiondefense
get_oldpeons 8
build 1 gateway 80
wait_buildstart 1 gateway
build 2 pylon 80
wait_buildstart 2 pylon
build 1 gateway 80
wait_buildstart 1 gateway
wait 10

stop

:block1early
wait 100

start_town
build 1 nexus 150
wait_buildstart 1 nexus
build 1 pylon 80
wait_buildstart 1 pylon
wait_build 1 pylon
wait_build 1 nexus
multirun block13
build 1 gateway 80
wait_buildstart 1 gateway
multirun expansiondefense
build 2 pylon 80
wait_buildstart 2 pylon
wait 1

:stargate
wait 1 

notowns_jump cybernetics_core stargate
wait 1
wait_build 1 fleet_beacon
wait 1

build 1 stargate 70
wait_buildstart 1 stargate
wait 1

stop

stop

:block13
wait 50

build 1 probe 40
wait_build 1 probe
build 4 probe 40
wait_build 4 probe
build 7 probe 40
wait_build 7 probe
build 10 probe 40
wait_build 10 probe
build 12 probe 40
wait_build 12 probe
stop

:block4
wait 100

wait_build 1 citadel_of_adun
wait 24

upgrade 1 zealot_speed 70
wait 4000

stop

:block5
wait 100

wait_build 1 cybernetics_core
wait 50

upgrade 1 dragoon_range 70
wait 50

stop

:block2
wait 100

wait_build 1 forge
wait 50

creep 4
build 1 photon_cannon 80
wait_build 1 photon_cannon
build 2 photon_cannon 80
wait_build 2 photon_cannon
build 3 photon_cannon 80
wait_build 3 photon_cannon
build 4 photon_cannon 80
wait_build 4 photon_cannon
build 5 photon_cannon 80
wait_build 5 photon_cannon
wait 60
stop

:block6
wait 10

wait_build 1 observatory
wait 24

upgrade 1 observer_speed 70
wait 50

stop

:expand
wait 9200

expand 99 block1
wait 200

goto expand

:expansiondefense
wait 10

notowns_jump forge expansiondefense
wait 10

creep 4
build 1 photon_cannon 30
wait 1200

build 2 photon_cannon 30
wait 1200

build 3 photon_cannon 30
wait 1200

build 4 photon_cannon 30
wait_build 4 photon_cannon
stop

:shuttle
wait 24

notowns_jump robotics_support_bay shuttle
wait 50

upgrade 1 shuttle_speed 2
wait 400

stop

:carrierupgrade
wait 100

notowns_jump fleet_beacon carrierupgrade
wait 100

upgrade 1 carrier_capacity 20
wait 500

stop

:airupgrade1
wait 10

notowns_jump cybernetics_core airupgrade1
wait 100

upgrade 1 p_air_weapon 8
wait 3800

upgrade 1 p_plating 4
wait 3800

upgrade 2 p_air_weapon 4
wait 4500

upgrade 3 p_air_weapon 2
wait 500

stop



:attackT
wait 1

:Tattack1
attack_add 7 zealot
attack_prepare
wait 500
attack_do
attack_clear
clear_combatdata
wait 100

resources_jump 700 300 Tattack2
wait 1

goto Tattack1

:Tattack2
wait 1

notowns_jump cybernetics_core Tattack1
wait 1
attack_add 7 zealot
attack_add 8 dragoon
attack_prepare
wait 500

attack_do
attack_clear
clear_combatdata
wait 1

resources_jump 1000 500 Tattack3
wait 1

goto Tattack2

:Tattack3
wait 1

notowns_jump cybernetics_core Tattack1
notowns_jump templar_archives Tattack2
wait 1

attack_add 12 dragoon
attack_add 4 dark_templar
attack_add 5 zealot
attack_prepare
wait 600

attack_do
attack_clear
clear_combatdata
wait 1

resources_jump 1100 900 Tattack4
wait 1

goto Tattack3

:Tattack4
wait 1

notowns_jump cybernetics_core Tattack1
notowns_jump templar_archives Tattack2
notowns_jump fleet_beacon Tattack3
wait 1

attack_add 3 carrier
attack_add 9 dragoon
attack_add 3 dark_templar
attack_add 4 zealot
attack_prepare
wait 600

attack_do
attack_clear
clear_combatdata
wait 1

resources_jump 1100 900 Tattack4
resources_jump 1000 550 Tattack3
resources_jump 650 300 Tattack2
wait 1

goto Tattack1



:attackZ
wait 1

:Zattack1
attack_add 9 zealot
attack_prepare
wait 500
attack_do
attack_clear
clear_combatdata
wait 100

resources_jump 900 300 Zattack2
wait 1

goto Zattack1

:Zattack2
wait 1

notowns_jump cybernetics_core Zattack1
wait 1
attack_add 8 zealot
attack_add 8 dragoon
attack_prepare
wait 500

attack_do
attack_clear
clear_combatdata
wait 1

resources_jump 1100 550 Zattack3
wait 1

goto Zattack2

:Zattack3
wait 1

notowns_jump cybernetics_core Zattack1
notowns_jump templar_archives Zattack2
wait 1

attack_add 7 zealot
attack_add 1 archon
attack_add 8 dragoon
attack_add 2 dark_templar
attack_prepare
wait 600

attack_do
attack_clear
clear_combatdata
wait 1

resources_jump 1200 800 Zattack4
wait 1

goto Zattack3

:Zattack4
wait 1

notowns_jump cybernetics_core Zattack1
notowns_jump templar_archives Zattack2
wait 1

attack_add 5 zealot
attack_add 5 dragoon
attack_add 1 archon
attack_add 4 zealot
attack_add 4 dragoon
attack_add 1 archon
attack_add 2 dark_templar
attack_prepare
wait 600

attack_do
attack_clear
clear_combatdata
wait 1

resources_jump 1200 800 Zattack4
resources_jump 1000 560 Zattack3
resources_jump 800 350 Zattack2
wait 1

goto Zattack1



:attackP
wait 1

:Pattack1
attack_add 10 zealot
attack_prepare
wait 500
attack_do
attack_clear
clear_combatdata
wait 100

resources_jump 800 400 Pattack2
wait 1

goto Pattack1

:Pattack2
wait 1

notowns_jump cybernetics_core Pattack1
wait 1
attack_add 7 zealot
attack_add 9 dragoon
attack_prepare
wait 500

attack_do
attack_clear
clear_combatdata
wait 1

resources_jump 1000 620 Pattack3
wait 1

goto Pattack2

:Pattack3
wait 1

notowns_jump cybernetics_core Pattack1
notowns_jump templar_archives Pattack2
wait 1

attack_add 7 zealot
attack_add 2 archon
attack_add 7 dragoon
attack_add 1 dark_templar
attack_prepare
wait 600

attack_do
attack_clear
clear_combatdata
wait 1

resources_jump 1200 800 Pattack4
wait 1

goto Pattack3

:Pattack4
wait 1

notowns_jump cybernetics_core Pattack1
notowns_jump templar_archives Pattack2
wait 1

attack_add 2 archon
attack_add 7 zealot
attack_add 8 dragoon
attack_add 2 carrier
attack_prepare
wait 600

attack_do
attack_clear
clear_combatdata
wait 1

resources_jump 1200 800 Pattack4
resources_jump 1000 650 Pattack3
resources_jump 800 350 Pattack2
wait 1

goto Pattack1

If this does work, I could add a lot of variations in the script in the future.

Thanks again for all your help and support, Archon_Wing. Without you I would never have been able to come this far. :)
EDIT: Thanks for the tip about guard_resources. I'll definitely try to use that command.
User avatar
Archon_Wing
Posts: 903
Joined: Wed Jul 25, 2007 11:22 pm

Postby Archon_Wing » Fri Apr 10, 2009 2:03 am

I also noticed that I probaby need more drones/scv's/probes for my AI's. I hope I'll be able to one day to move the drone production to a separate thread. I played a game earlier today and I noticed that when I took out a few drones the AI would practically do nothing until they were replaced.


Watch out for leftover wait_build/waitbuildstart commands. If you have them for drones that don't exist anymore, it'd halt the acript.

Terran and Protoss can easily have workers multirun. Zerg is a bit trickier just because they have to balance out larva use, you can try giving workers a lower priority for zerg. For the others, you'd need stuff like wait_build 10 probe to build your buildings in a timely fashion then.

Archon_Wing, I hope you don't mind me asking this question. I've made several changes to the scripts for version 0.3. I don't really know though if these changes are for the better or for the worse. I've tried to put the main attacks in a multirun thread, so it would run independently from the main thread, as well as allowing the AI to keep fighting even when almost all buildings are destroyed. (I'll give you full credit for this because I saw your example in the "How to make a better AI" thread.)


Actually, I suggested the attacks be in the main thread and have the rest of the building in a multirun. Early attacks could be multirun though. From my experience it really doesn't matter which is where though, as long as they are kept in seperate threads. If you put the building in the main thread and have it stop when the building is done, the attacks would act as the main thread anyways.

I wouldn't say the idea is mine; since I got it from reading around these boards, though I've never seen a script that uses them exclusively until I made my own. ;) And actually Blizz default has something close to the idea; it's just that it was way more cluttered.

Thanks again for all your help and support, Archon_Wing. Without you I would never have been able to come this far.


np ^^

One thing I'd suggest is to make the looping checks longer, say 500 (which is about 20 seconds), because things won't change that fast. Things that are extremely important can have shorter loops, of course.
User avatar
JH24
Posts: 323
Joined: Sat Mar 14, 2009 6:25 pm

Postby JH24 » Mon Apr 13, 2009 7:32 pm

A quick update.


I knew when I began that AI scripting is very difficult, but I got so much problems with my Zerg script this weekend that I really had a moment were I just wanted to throw everything away and quit. Eventually, I did manage to get the Zerg script working again. (It would only do an attack loop once, and despite my specific order to keep repeating it it would do nothing anymore after the first time. Now it works again but I don't really know yet how I solved this. These AI scripts are so fragile.


On the positive side, I made a lot of changes and in general, all three AI's have improved and become stronger. All three have three different starting builds depending on race, there are seveal resource-checks to make sure the AI will not develop further or waste money needelessly, and it will make use of a larger variety of units, when resources and circumstances allow. (Ultralisk, Archon, Battlecruiser, Mutalisk, Dark_Archon, Science-Vessel, etc.)



I'm not entirely sure yet though if I should allow the Zerg AI to make Lurkers. Would it be better if I invest more in Mutalisks instead of Lurkers? In a way, Lurkers are great against marines and Zealots, but the AI often seems to unburrow them when the enemy is approaching.
User avatar
Archon_Wing
Posts: 903
Joined: Wed Jul 25, 2007 11:22 pm

Postby Archon_Wing » Mon Apr 13, 2009 9:01 pm

You could always make it run if the comp has lots of gas, but don't let it conflict with the other hydra upgrade. It's best if all the den upgrades and lurker training was all in the same place. I've noted the comp will use lurkers to attack as long as they have a defenseuse command, even if you don't specify them in your attacks. Actually the comp seems to do that with a lot of units.
User avatar
JH24
Posts: 323
Joined: Sat Mar 14, 2009 6:25 pm

Postby JH24 » Wed Apr 15, 2009 8:19 pm

@ Archon_Wing, I've added a resource_check for Lurkers, but it will only come after the other Hydralisk upgrades are complete. I wonder how this will work.

Test AI version 0.3 (See first post)
I've updated my first post with a new version of my AI. All three AI's should have become at least a little stronger and more stable in general. The biggest improvement for this version has to be (as far as I could test) the managing of the economy by the AI's (Even the Zerg, which gave me so much trouble with their behavior last weekend) In general, all AI's are now able to quickly expand their resource gathering in combination with their military development. At least I hope it will give me a more solid base to improve my AI further in future versions.

General changes:
- Better resource management.
- Different opening builds depending on the opponent the AI is facing.
- Added resource_checks to make sure the AI won't upgrade to a higher tier unless it has enough resources to build through and support it.
- Added several random attacks in the first part of the script.
- Added resource_ and notowns_jump trigger based lists for all three sides, which will determine the size of the AI's attacking forces. This way, even when the AI is losing, it will try keep fighting and resisting until the end.
- The upgrades for armor and weapons differ for each opponent the AI is facing. It will prioritize certain upgrades to cover for certain weaknesses. (Example: Protoss are weak against Terran's EMP Shockwave. So the Protoss AI will instead try to upgrade its armor and weapons as fast as possible, as spending money on Plasma Shields might be potentially a waste.

Likewise the Protoss AI might prioritize upgrading Plasma Shields against Zerg regarding Plague instead of upgrading its Armor.

Race-based changes:
Terran:
- More balanced opening build.
- Against Terran and Protoss, heavier emphasis on Siege Tanks.
- Against Zerg, more emphasis on M+M and Goliaths.
- Early detection build, early focus on Comsat and Turrets.
- More variety added, might build Battlecruisers and Science Vessels if the resources are available.
- Added specific tech and upgrades depending on race. Example: Against Protoss the Terran will tech EMP shockwave, against Zerg Irradiate.

Zerg:
- Re-balancing opening build. Still somewhat weak, but strengthened Mid- and High Tier.
- Tweaked resource gathering.
- Tweaked upgrade paths and teching, more race dependant.
- Lurker and Ultralisk upgrades will only be researched if specific conditions are met.
- Added support for Mutalisks, Ultralisks and Defilers.
- Increased waiting time between expanding from 7500 to 8800.
- Tweaked early defense regarding Corsairs or rushes.
- Reduced dependancy on Ultralisks in favor of other units.
- Removed support for Guardians. (Too expensive, maybe in later versions)

Protoss:
- Decreased the time between expanding from 9200 to 8800.
- Tweaked resource gathering.
- Tweaked early unit production.
- Tweaked early defense build regarding photon cannons.
- Removed most of the early attacks as they seemed to slow AI down.
- Tweaked mid-game random attacks.
- Added Reaver support for Protoss, AI will use them more often and more agressively.
- Tweaked AI to build observers as soon as possible.
- Carriers, Dark_Archons, Archons, Dark_Templar, High_Templar are all added/supported for more variety. Their actual use remains resource dependent though, so they might not appear very often.

Problems I'd like to fix in future versions:
- Less dependency on "train" commands.
- Improved balancing between resources and unit production.
- Trying to decrease the Zerg AI's "slowness" at points. (The AI seems to be waiting for something at times)
- Trying to add and experiment with "reactive" scripts.

The scripts for version 0.3a are added in my first post too.
Thanks for reading! :)
User avatar
Archon_Wing
Posts: 903
Joined: Wed Jul 25, 2007 11:22 pm

Postby Archon_Wing » Wed Apr 15, 2009 9:09 pm

I have edited your first post so your download appears on the front page. (You can't see attachments on front page articles and many people just won't go to the forums) and also a "cutoff" read more... link. You can edit them however you like, though. You may also consider adding a screenshot of some gameplay.

The upgrades for armor and weapons differ for each opponent the AI is facing. It will prioritize certain upgrades to cover for certain weaknesses. (Example: Protoss are weak against Terran's EMP Shockwave. So the Protoss AI will instead try to upgrade its armor and weapons as fast as possible, as spending money on Plasma Shields might be potentially a waste.

This is a good idea, since emp isn't really that useful against zerg. ;) Plasma shields tend to be a low priority upgrade since they are so expensive.

Edit: Two reps, both tvz. First game involved mech, the second game was the more ordinary bio infantry thingy.

Problems
-Defense
The early defense seemed fairly weak at about the 7 minute mark. You can see in the bio replay that a small group of m+m was about to break through. Normally that attack isn't really designed to kill, as it was done after a fast expand, so 1 base no expand "all in" m+m rushes (something like Racine/Raynor Terran AI does) would prove fatal.

Against terran, I'd recomend no less than 3 sunks and maybe a dozen lings as defense against terran, unless you are building massive amounts of lings or lurkers, then you could do with less. On the other hand, you usually wouldn't need more than one sunken colony against other zerg since sunkens aren't that great against zerglings. In the mech replay, the early vultures did some damage, but not fatal. This wasn't too bad. You can just have an enemyowns_jump factory in your expansion to decide to get early hydralisks or maybe a sunken in the expansion block (does not need to be loop)

- Opening build order.
You're probably aware of this by now, but it's usually not too great to get an early pool without being aggressive. A few ways to deal with this is to script a random zergling attack. If you don't feel like attacking in favor of economy, you can just time the pool according to other people by using "rush 0" Rush 0 checks for military buildings, complete or incomplete.

Something like this. IMO, this is the best way an AI can handle early rushes without being easily exploited. Due to its poor micro, it won't block 100% of rushes, of course, but it should catch most of them and offer a chance for a immediate counterattack.

Code: Select all

build 6 drone 80
wait_buildstart 6 drone
enemyresources_jump 80 0 6pool
build 9 drone 80
wait_buildstart 9 drone
rush 0 9pool
build 12 drone 80
wait_buildstart 12 drone
rush 0 12pool
goto 12hatch


My zerg script has something like that. The reason I used enemyresources_jump for the 6 pool is because your opponent won't have a building yet, and has to save up resources for it. Either that, or he/she sucks. Either case, a 6 pool is perfect. ;) You can also stick random jumps to mix it up a bit. It'd make it more complex with the extra blocks, but not really since the only diffrence is when you build the pool, so copy and paste deals with it easily.

But on second thought, since terran rushes are weaker, you can just run the check earlier because the terran would need to build a barracks a bit earlier than the spawning pool to be a real threat:

Code: Select all

vs terran:
build 8 drone 80
wait_buildstart 8 drone
rush 0 9pool
build 10 drone 80
wait_buildstart 10 drone
rush 0 12pool
goto 12hatch

The other thing is that lair has to be gotten pretty fast vs terran, unless it is a very aggressive AI like storm zerg, and even that gets lair faster than the other two matchups. Asssuming no early attacks you'd want a build order like 12 hatch, 11 pool, 13 hatch. You can switch these things around a bit if you picked another build, of course.

- Expanding
The last thing I saw was the Ai didn't really expand too much. The zergling guard at resources is pretty annoying though.

Anyhow good luck; I think you will have a major breakthrough in the AI soon ^^.

Return to “StarCraft Modding”

Who is online

Users browsing this forum: No registered users and 1 guest