COUNTERZERG - an ai by avance70

Help - Resources - AI Scripting - Grafting - Plugins - Modding Projects
User avatar
Xerxes
Posts: 43
Joined: Wed Dec 24, 2008 9:38 am

Postby Xerxes » Sun Dec 28, 2008 10:35 am

[quote name='Archon_Wing' post='1381' date='Aug 3 2007, 05:51 PM']Wow, nice macro and micro. It'd be nice to see it when it develops tech![/quote]

Wish granted, if avance70 will give me a thumbs up for this. Out of curiousity I decided to make some minor modifications to CounterZerg, because it is my favorite non-cheating Zerg AI script here, but it suffers from a few glaring weaknesses. Here's the scoop on my experiment:

[spoiler]My CounterZerg modification added the following steps:

1. Morph to Lair while finishing first upgrades
2. Quickly get Pneumatized Carapace for detection purposes
3. Upgrade Melee and Carapace to Level 2
4. Morph a Queen's Nest, then a Hive while waiting on second upgrades
5. Adrenal Glands immediately on Hive completion
6. Get Ventral Sacs to enable island expo/attack options
7. Upgrade Melee and Carapace to Level 3
8. Finish by leisurely upgrading Missile Attacks to 1, 2 and 3
9. (added later) Send suicide wave if resources accumulate to 3500/1500 (read notes on Round 4 below)

Resources spent from steps 1-7: 1925 Minerals, 1775 Gas
Resources spent to finish step 8: 450 Minerals, 450 Gas
Total Extra Expenditures: 2375 Minerals, 2225 Gas

Assuming we already had enough Overlords and were replacing lost units, that's enough resources to have spawned 76 Zerglings or 25 Hydralisks instead by the time we've completed Step 7. Will this diversion of resources put it at a disadvantage against the original script? Let's find out! (If you're wondering why I'm calculating only up to Step 7, it's because most of the matches didn't last more than a couple minutes beyond this step. The Missile Attack upgrade was seen no higher than 1 in the longest match.)

Map: WGTour Lost Temple 2.2
CounterZerg Match 1v1 Round 1: Modified CZ wins at 24:18
CounterZerg Match 1v1 Round 2: Modified CZ wins at 28:15
CounterZerg Match 1v1 Round 3: Modified CZ wins at 24:40
CounterZerg Match 1v1 Round 4: Stalemate; see below
CounterZerg Match 1v1 Round 5: Modified CZ wins at 27:35
CounterZerg Match 1v1 Round 6: Modified CZ wins at 29:48

Win Ratio: 100%

Because of CounterZerg's impressive production rate, there are many back and forth battles here between the two scripts, where neither gains much ground, especially since they're pushed back so quickly by new units produced at eachother's main bases when attacking them. So the decisive variables in these matches seem to be where they choose to attack.

In the 2nd Round, the original CounterZerg script launches its first attack against two undefended expansions, wiping them out and leaving the modified script with nothing but its main base and natural expansion. The rest of the match saw the modified script battling against superior numbers of Zerg, but the upgrades made such a difference that it was able to eventually overpower its opponent even though it only had two expansions (rebuilt one) to the enemy's four.

Needless to say in the other matches where the modified script's economy wasn't partially crippled, the upgrades turned the tide of the battle against the original script.

Further notes regarding the 4th and 6th Rounds:
[spoiler]**Regarding the 4th Round: I'm not sure what happened here but it looks like sometimes the CounterZerg script reserves a couple Hydralisks in the base for defense when it sends an attack wave. The original script was pretty much defeated this match and had lost everything but the main when the modified script seemed to lock up due to max population with Hydralisks sitting all over it's base around 25 minutes. Teal's base was loaded with them as well, though not as many. I'm thinking about adding a resouces_jump loop after the upgrades are finished to force the AI to attack periodically if its resources are too high (say 3500/1500), which should be a safe indicator that it's not building anything. The original script rebuilt its half-dead base and launched two more attacks but was repelled easily by the other AI's standing Hydralisk army and Sunken Colonies, and ran out of resources at it's remaining expansions. The modified script clearly won this battle but I gave the original some credit for fighting on its last legs and called it a draw. ;)

**6th Round: I decided to do an extra since I intended on checking for five match results and the 4th stalemated. Before I launched the 6th Round I made the resource check/suicide send modification described above, and instructed the script to send 2-4 more units per attack than it had actually built for that attack to try to alleviate the parked Hydralisk issue. This match went a bit longer than usual because the modified script was having some bad luck with attack timing and kept engaging the opponent from the bottom of a ramp. This was the first match I saw it smoothly expand into one of the corner islands, putting the Ventral Sacs to good use in the process and securing an expansion the other CounterZerg script could never destroy. The big kicker though was when it stashed up a ton of resources and triggered my send_suicide resource check - instead of attacking with 50 units, it threw the kitchen sink and must have had over 100 Hydralisks lounging about that dashed into the fray. The original CounterZerg script was doing pretty good at this point and still had three expansions and it's main mostly undamaged; it got steamrolled by the massive attack in about three minutes flat (and it only took that long because the mass of units was slow to get from one base to another around hills and through ramps).[/spoiler]

So clearly the small modifications I made to the script have made a significant impact, but will it fare better against human opponents than the original? My final test will be to test it against two of my friends who've beaten it before. The first played PvZ and hid on an island one match and built an air fleet after losing their main, and CounterZerg couldn't reach them to destroy them without Overlord tech. The second beat it ZvZ utilizing a wall of Sunken Colonies and Lurkers, holding CounterZerg off easily while creating Guardians to wipe it out. CounterZerg's slow Overlords never got anywhere near the wall in time to reveal the Lurkers, resulting in repeated massacres. I pitted them both against my modified CounterZerg in a 2v2. They both selected the same races. Can they beat it again? Will they try the same strategies?

The battlefield chosen was Aftershock (6 player map in the Brood War folder). The Zerg player attempted an early Zergling attack against one opponent, but CounterZerg's freshly completed Sunkens at the early expansion repelled it with ease. The Zerg player continued by utilizing a mix of Sunken Colonies, Lurkers and Zerglings at main and natural for defense and was starting to build a Spire around 23 minutes. The Protoss player built a Photon wall to protect the nat and expanded into it early, adding a Shield Battery and a pack of Zealots before starting to build Scouts, and had just deployed a Shuttle with some Dark Templar to expand on top of one of the plateaus.

By now CounterZerg had launched several attacks, both of them focusing mostly on the Zerg opponent. These were easily butchered by the increasing number of Lurkers protecting the Zerg player's natural, until CounterZerg showed up with it's new Pneumatized Carapace upgrade. A simultaneous attack by both CounterZerg AIs with a mix of Zerglings and Hydralisks on the Zerg player quickly overwhelmed the enemy Lurkers with Overlords providing detection support, and the Zerg player's base was leveled in minutes flat before air units could be produced.

With most of their units intact, the triumphant CounterZerg turn their attention to their Protoss opponent, gathering outside his Photon blockade in increasing numbers as second attack groups join from both sides. They dash in, outnumbering the Zealots five to one, and effortlessly smash through the blockade, tearing apart the base. Four Scouts made a desperate attempt to fend off the Zerglings until Hydralisks could manuever past them and close in for the kill.

This left the modified script's final test; the Protoss player had an expansion left on the plateau guarded by a couple Photon Cannons and Dark Templar. But because CounterZerg was now using Overlords properly for detection and transportation, it was able to squash this in one minute. The original CounterZerg script never builds air units and doesn't use the Ventral Sacs upgrade, which would have allowed the Protoss player to survive indefinitely.

Both of my friends were good sports and gave the adjustments an approving thumbs up, with the Zerg player commenting "Ouch."

It probably would've taken the CounterZerg script an additional attack against the Zerg player to have broken the Lurker defense one on one, so admittedly having another CounterZerg ally expediated the victory, but it definitely would have beaten that strategy without an ally. Overall I'd say the script's effectiveness appears to have been improved just as much against human opponents as it was against itself.[/spoiler]

avance70: Because of the immense difference I've enjoyed with this, I'd like to share it with everyone else here with your permission. There's two ways we could do this. If you're interested and have the time, I'd happily PM you the exact changes and code I made so you can reproduce them, try it, and release it as an update yourself if you approve.

If you're very busy, I can simply upload the modified script here for everyone, as long as I have your permission; this is your creation. It's been a lot of fun to play against in the game and an interesting, but this minor adjustment makes it even more formidable, and the additional upgrades should allow the vast numbers of Hydralisks at it's disposal to deal with virtually any air threat, sans massive numbers of Guardians or Battlecruisers.
User avatar
Xerxes
Posts: 43
Joined: Wed Dec 24, 2008 9:38 am

Postby Xerxes » Sun Dec 28, 2008 8:16 pm

Yes I will certainly test it further against the other AI scripts here after I've put together a new self-executable or two for it. I agree a CounterZerg script utilizing air units would be interesting to see, but I really like how it sticks to its guns with this pressure strategy. It's fairly unique and I wouldn't want to take that away.

I was wondering though, in the BWAI War replays, which internal script IDs are used for same race matches? TMCu, ZMCu and PMCu, right? I didn't find the info in the notes or thread. Might have missed it?

Edit: Nevermind, found the launcher in another download elsewhere on the site.
User avatar
Archon_Wing
Posts: 903
Joined: Wed Jul 25, 2007 11:22 pm

Postby Archon_Wing » Wed Feb 11, 2009 9:59 pm

Any word on this, Xerxes? ;p
avance70
Posts: 34
Joined: Tue Jun 12, 2007 2:01 pm

Postby avance70 » Wed Aug 12, 2009 9:30 am

hey sorry i just had to quit like that
i got a job and it pretty much consumed all of my time on the beginning

its nice to see all the improvements you made, and you have all the thumbs up i can offer :D

also, thanks again to all that sent in their replies and comments
should i ever again find the time, id be glad to come back and try to code more zerg stuff ;)
User avatar
Archon_Wing
Posts: 903
Joined: Wed Jul 25, 2007 11:22 pm

Postby Archon_Wing » Thu Aug 13, 2009 1:57 am

Glad to see you still around. Your original script is still the most effective macro script, and unforunately we never got to saw the changes made as Xerxes never came back. I tried to do some changes in Entropy Prime but I don't really know how well it works.

Also check out BWAPI, which is capable of far more than scripting.
User avatar
Archon_Wing
Posts: 903
Joined: Wed Jul 25, 2007 11:22 pm

Postby Archon_Wing » Sat Jan 16, 2010 11:14 pm

Here's a modified version of the script (in BWAI launcher format of course) that is lying around my Entropy folder. I had added lair tech, however it was very tacked on and was questionable in quality, the main problem being the tech was added to suddenly as opposed to gradually as it should be.

I made a few changes to it. The lair stuff does not start til around 15 min as to avoid impacting its performance earlier in the game. It does, however, get hydralisk range, which the original script didn't. :lol: Hopefully it can be comparable to what Xerxes tried, so if you were waiting around for it for some reason, you can try it now!

I'm also pretty terrible at scripting zerg, especially scripts not made by me, so someone could probably do a better job at this. It is a mere 30 line addition to the orginal script. Don't expect any groundbreaking changes, as it was not meant to be drastic.

Changes:
Gets hydralisk range after speed finishes, as well as missile.
Morphs lair @ 15-16 minute mark
When lair is almost done, build a 3rd evo chamber
Upgrade OL speed, get all lvl 2 upgrades
Wait a bit for queens nest then Hive, get all lvl 3 upgrades, transport, crackling


Purpose of getting a lair:
Upgrades, and overlord speed are needed to compete late game, otherwise it gets less and less effective.

edit: uploaded version w/o unused blocks.
User avatar
Xerxes
Posts: 43
Joined: Wed Dec 24, 2008 9:38 am

Postby Xerxes » Tue Jul 20, 2010 9:46 pm

No doubt very late, but after much digging around I finally found the test executable with the modified code for the CounterZerg script as described above. The timing for some of the tech/upgrades might be adjusted slightly, but based on the test matches it seemed to do quite well. I also noticed transports_off() and farms_notiming() were added to the start of the script, but I can't say if they did anything.

Feel free to do whatever you like with this code. I want no credit of any kind, just had fun working with it. You made a very nice script, avance70, and you are kind to let an AI novice toy around with it.


Original CounterZerg code for block CNTZ 0004 (excluding stuff beyond stop()):
[spoiler]

Code: Select all

      --CNTZ 0004--
   wait_build(1, Zerg Extractor)
   build(1, Zerg Evolution Chamber, 80)
   wait_build(1, Zerg Evolution Chamber)
   upgrade(1, Zerg Melee Attacks, 255)
   wait(300)

   wait_build(1, Zerg Hydralisk Den)
   build(2, Zerg Evolution Chamber, 80)
   wait_build(2, Zerg Evolution Chamber)
   upgrade(1, Zerg Carapace, 70)
   upgrade(1, Muscular Augments, 70)
   wait(300)

   stop()
[/spoiler]
Here's the modified CNTZ 0004 block with added resource attack check, blocks CNTZ 0108 & 0109:
[spoiler]

Code: Select all

      --CNTZ 0004--
   wait_build(1, Zerg Extractor)
   build(1, Zerg Evolution Chamber, 80)
   wait_build(1, Zerg Evolution Chamber)
   upgrade(1, Zerg Melee Attacks, 255)
   wait(300)

   wait_build(1, Zerg Hydralisk Den)
   build(2, Zerg Evolution Chamber, 80)
   wait_build(2, Zerg Evolution Chamber)
   upgrade(1, Zerg Carapace, 70)
   upgrade(1, Muscular Augments, 70)
   wait(2000)

   build(1, Zerg Lair, 50)
   wait_build(1, Zerg Lair)
   wait(300)

   upgrade(1, Pneumatized Carapace, 60)
   wait(150)

   upgrade(2, Zerg Melee Attacks, 40)
   upgrade(2, Zerg Carapace, 40)
   wait(1500)

   build(1, Zerg Queen's Nest, 40)
   wait_build(1, Zerg Queen's Nest)
   wait(600)

   build(1, Zerg Hive, 50)
   wait_build(1, Zerg Hive)
   upgrade(1, Adrenal Glands, 60)
   wait(600)

   upgrade(1, Ventral Sacs, 60)
   wait(600)

   upgrade(3, Zerg Melee Attacks, 40)
   upgrade(3, Zerg Carapace, 40)
   wait(3600)

   upgrade(1, Zerg Missile Attacks, 40)
   wait(2700)

   upgrade(2, Zerg Missile Attacks, 40)
   wait(2700)

   upgrade(3, Zerg Missile Attacks, 40)
   goto(CNTZ 0108)


      --CNTZ 0108--
   resources_jump(3500, 1500, CNTZ 0109)
   wait(50)

   goto(CNTZ 0108)


      --CNTZ 0109--
   send_suicide(0)
   wait(21600)

   goto(CNTZ 0108)
[/spoiler]
User avatar
Archon_Wing
Posts: 903
Joined: Wed Jul 25, 2007 11:22 pm

Postby Archon_Wing » Fri Jul 23, 2010 12:46 am

Ah nice, could you upload the entire txt file? Though you might also want to compare it with the modified version I posted slightly above
User avatar
Myk
Posts: 257
Joined: Sat Jun 13, 2009 12:56 pm

Postby Myk » Sun Aug 01, 2010 3:46 am

Xerxes' update doesn't get Grooved Spines (Hydralisk Range).

I like both updates. The script really benefits from the extra upgrades to keep the Hydra/Ling army strong.

Return to “StarCraft Modding”

Who is online

Users browsing this forum: No registered users and 1 guest