#!/usr/bin/env bash
# Regenerate test/goldens.txt from current binary output. Run only after
# intentional changes to generation logic.
set -eu
cd "$(dirname "$0")/.."
BIN=./bin/genesis
OUT=test/goldens.txt

if [[ ! -x "$BIN" ]]; then
    echo "error: $BIN not built. Run 'make' first." >&2
    exit 2
fi

# Pairs of seed:depth. Mix shallow (water) and deep (lava/chasm/brimstone) to
# cover the full liquid range.
PAIRS=(
    "1:1" "2:1" "42:1" "77:1" "1234:1" "2026:1" "9999:1"
    "123456:1" "31337:1" "7:1" "100:1" "500:1"
    "2026:10" "2026:15" "2026:20" "2026:25"
    "1234:18" "9999:22"
)

{
    echo "# seed_depth|map_sha256|summary_line"
    echo "# Generated $(date -u +%Y-%m-%dT%H:%M:%SZ)"
    for pair in "${PAIRS[@]}"; do
        seed="${pair%:*}"
        depth="${pair#*:}"
        hash=$("$BIN" --seed "$seed" --depth "$depth" 2>/dev/null | sha256sum | awk '{print $1}')
        summary=$("$BIN" --seed "$seed" --depth "$depth" --quiet 2>&1 >/dev/null)
        printf '%s:%s|%s|%s\n' "$seed" "$depth" "$hash" "$summary"
    done
} > "$OUT"
echo "wrote $OUT ($(wc -l < "$OUT") lines)"
