# 4-POOL -- Zerg. THE SHIPPED BUILD: this file is bundled into the jar as
# scripts/zerg-default.txt and is what plays on the ladder.
#
# Measured on (2)Benzene, 20 games per matchup:
#   vs Terran   100%  (20/20, 84-100%)
#   vs Zerg     100%  (20/20, 84-100%)
#   vs Protoss   85%  (17/20, 64-95%)
#   overall      95%  (57/60)
#
# For comparison the deleted hardcoded book managed 82-100% / 93-95% / 30%.
#
# The no-micro control is local/scripts/fourpool-nomicro.txt (70% vs Protoss).
# Measure any change against THAT, not against this file, and re-check all three
# races before keeping it.
#
# Run:  ./local/run-batch.ps1 -Games 20 -Label <name> -Script local/scripts/fourpool.txt

# --- Opening -----------------------------------------------------------------
# NO GAS. 4-Pool spends every mineral on Zerglings; a Drone on gas is a Drone not
# mining, and gas buys nothing in this build.
gas 0

# The Pool goes down IMMEDIATELY, at the 4 Drones we start with. That is the whole
# build -- "4-Pool" is the supply it is built at. Queueing it first also reserves
# its 200 minerals, so nothing below can spend them out from under it.
#
# Measured: this puts the Pool down at ~0:34 and complete at ~frame 2250, which
# matches the deleted book's recorded poolFrame=2258 almost exactly.
make pool 1

# Replace the Drone the Pool ate, and no more. Every mineral past this is Zerglings.
# The old book capped Drones at 7 (9 vs Protoss, whose game lasts longer); 5 is that
# cap expressed as a floor, since nothing here ever asks for a sixth.
keep drone 5

# --- Army --------------------------------------------------------------------
# The instant the Pool can produce, every larva becomes Zerglings, forever. A big
# number rather than a finite order: this must not run out mid-game and quietly
# stop, which is what "make ling 12" would do.
#
# "have pool" is COMPLETED-only. Firing on a Pool still under construction would
# issue larva orders ~40s early, all of them silently rejected.
#
# NOTE: this parks 90-odd Zerglings at the head of the build queue for the rest of
# the game. Nothing else in THIS script needs the queue, but any building added
# below would sit behind them forever (head-of-line blocking). Use `task build` or
# `expand`, which do not go through the queue, if you add one.
when have pool -> keep ling 99

# Attack at 6, and never sit at home again. The old book's ATTACK_AT_LINGS was 6
# for every race, and waiting for more is how a 4-Pool loses: the whole build is a
# bet that 6 Zerglings arrive before the defence exists.
when have ling >= 6 -> attack

# --- Deliberately NOT here ----------------------------------------------------
# Things the first live game made tempting, and why each one waits for a baseline:
#
# * A SECOND HATCHERY on surplus. That game banked 482 minerals at 4:23 with 0
#   larvae -- one Hatchery cannot spend a 5-Drone income on Zerglings. But the book
#   had MAX_HATCHERIES=1 during the rush and still measured 30%, so adding one is a
#   DIFFERENT BUILD, not a bug fix. Worth testing as `fourpool-2hatch`, via
#   `every minerals >= 400 -> task build hatchery` (not `make`: see the queue note).
#
# * A MIDGAME TRANSITION at ~8:00 (Drones back up, expand, tech). The book had one
#   behind a flag, and the README's verdict on it is blunt: "everything that extends
#   the game: 0%". Against the built-in AI, surviving is anti-correlated with
#   winning -- it out-masses us in long games. Losing faster is not worse here.
#
# * A STAGING RULE (hold reinforcements until the pack is together). Aimed at the
#   trickle that lost an early game 14 Zerglings for 0 kills. Implemented as
#   `micro stage` but never measured -- and note that 'stage' would REPLACE
#   'micro surround' below rather than add to it, since a unit has one policy.

# --- Combat -------------------------------------------------------------------
# SURROUND: the whole squad commits to ONE target and encircles it.
#
# Measured vs Protoss, 20 games each:
#   no micro   70%  (14/20, 48-85%)   <- local/scripts/fourpool-nomicro.txt
#   focus      45%  ( 9/20, 26-66%)   per-unit target + attacker cap
#   gang       60%  (12/20, 39-78%)   shared target, no positioning
#   surround   85%  (17/20, 64-95%)   shared target + encircle
#
# The ordering is the finding. Per-unit targeting is WORSE than no micro at all: it
# spreads a six-Zergling rush across six victims, and a rush wins by concentrating
# damage. Concentration alone (gang) does not beat doing nothing either -- the gain
# needs the positioning too, because melee units are limited by how many can
# physically reach the target at once.
#
# Terran and Zerg re-checked at 20/20 each, so this is not a Protoss-only win. That
# check exists because surround-as-a-global-flag once took Zerg 100->71% and Terran
# 100->50% while helping Protoss (see README, "Experiments run").
when have ling >= 1 -> micro surround
