#!/bin/bash
# queued builds for the taste teacher's data (Oct 23 2026). It decides when each build is done; 150 turns is only a safety stop.
# Stops queuing if the weekly subscription meter passes 60%.
cd ~/projects/brick_reef/reef
until python3 -c "import json,sys; sys.exit(0 if json.load(open('runs/me3/state.json'))['stage'] in ('done','stopped') else 1)"; do sleep 10; done
for n in 4 5 6; do
  w=$(subusage 2>/dev/null | awk '/^week/{gsub("%","",$2); print int($2)}')
  if [ -n "$w" ] && [ "$w" -ge 60 ]; then echo "weekly meter at $w%, stopping the queue" > runs/queue_stopped.txt; exit 0; fi
  python3 imagine.py --turns 150 --seed $((20 + n)) --name me$n > runs/me$n.log 2>&1
done
