Playbook

A playbook is what the SC2L compiler produces. It contains expression trees, milestone definitions, handler descriptors, and constants — everything the runtime needs to execute a strategy.

Unlike compiled code, a playbook is pure data. It can be inspected, diffed, versioned, and hot-swapped without restarting the runtime.

Properties

  • Portable — runs on desktop, mobile, and web via a single runtime
  • Inspectable — human-readable structure for debugging and visualization
  • Hot-swappable — load new playbooks at tick boundaries without restart
  • Deterministic — same playbook produces identical execution across platforms
  • Compact — typically 10-50 KB

Contents

  • Expression trees — conditions and computations as evaluable trees
  • Milestone definitions — state-by-time contracts with requirements and priorities
  • Handler descriptors — event reactions and tactical responses
  • Constants — named values, timings, and thresholds

Example

A playbook compiled from the SC2L example:

example.playbook.json
; Root — runtime walks this tree each tick
(seq
  ; Economy invariants — checked every tick
  (invariant :never
    (var supply_blocked))

  (invariant :keep
    (var workers_building)
    :when (gte (var minerals) 50))

  ; Milestone — state-by-time contract
  (milestone "expand"
    :target 150
    :tolerance 15
    :require (gte (var base_count) 2)
    :on-miss
      (deviation :high "Missed expansion timing"))

  ; Handler — event reaction subtree
  (on (event EnemyNear (var natural))
    (until (eq (var threat) 0)
      :timeout 60
      (seq
        (act attack_move
          (group defenders
            (filter (var owned.units)
              (eq (var type) Stalker)))
          (var natural))
        (sleep 2)))))
← Back to home