# 4-POOL -- Zerg. The measured best opening this project has:
#   30% vs Protoss, 93-95% vs Zerg, 82-100% vs Terran (README, ~500 games).
#
# Those numbers were produced by a hardcoded Java strategy that has since been
# deleted. This script is the claim that the engine can reproduce it from the
# outside, using nothing but commands an operator can type. If it measures the
# same, the deletion cost nothing. THAT IS THE EXPERIMENT, and it is the reason
# this file is a faithful copy rather than an improved one.
#
# Run:  ./local/run-batch.ps1 -Games 20 -Label fourpool-script `
#           -Script local/scripts/fourpool.txt
#
# DO NOT "fix" this script until it has a baseline number. Deviations belong in a
# copy with its own label, measured against this one -- see the notes at the end,
# which list the improvements that are tempting and what the book measured them at.

# --- 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

# --- First unattended result --------------------------------------------------
# WIN vs Terran at 6:29 (frames=9271), 36 kills for 21 losses. Pool down 0:37,
# complete 1:31, attack 1:55 with 6 Zerglings. n=1, so it proves the script RUNS,
# not that it reproduces 82-100% -- that needs run-batch.
#
# --- 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.
#
# * COMBAT MICRO. The first game lost 14 Zerglings for 0 kills, trickling into
#   3 Zealots and a Shield Battery one at a time. The deleted book had focus-fire
#   with target priorities, an attacker cap per target, and a staging radius that
#   held reinforcements until the pack was together. NONE of that survives in the
#   engine, and no script can express it -- it is per-frame targeting. This is the
#   real gap between this script and the 30%, and it belongs in per-unit behaviours.
