Files
Richard HarringtonandClaude Fable 5 3a42cd1d69 Add six radar-driven robots for playtesting
Three strategies, each in a basic and a target-leading variant:

- sweeper: stationary 360-degree radar sweep, fires at contacts with
  the reported distance
- camper: drives to the top-left corner, sweeps a 90-degree arc, and
  re-navigates if knocked out of position
- hunter: sweeps, then charges along the contact bearing (via a
  triangle-wave approximation of sine, since the language has no trig)
  and fires point-blank once within 40 meters

The -lead variants re-ping after contact to estimate bearing drift and
aim ahead of it. All sweeps are jittered via the RANDOM register:
fixed-step sweeps sample the same discrete bearings forever, so two
stationary robots at long range could permanently miss each other
(verified in headless sims before the fix; after it, every duel ends
in 3-4.5 game-minutes).

Manifest: the trivial demos speedy and shooter are pruned;
mover/left-shooter/top-shooter stay as moving fodder. programs.json
mirrors programs-live.json per AGENTS.md.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-13 06:48:27 -04:00

97 lines
2.4 KiB
Plaintext

; HUNTER: sweeps until it finds a target,
; then charges along the contact bearing,
; re-pinging as it goes, and opens fire once
; within 40 meters. There is no trig in this
; language, so CHASE converts a bearing into
; X/Y speeds using a triangle-wave
; approximation of sine (TENT).
0 TO S ; S = radar bearing, kept near 0..360
4 TO RANDOM ; jittered sweep step, see sweeper.rw
LOOP
0 TO SPEEDX ; stop while scanning
0 TO SPEEDY
SWEEP
S + 4 + RANDOM TO S ; advance the sweep 4..7 degrees
IF S < 360 GOTO SCAN
0 TO S
SCAN
S TO RADAR
RADAR TO R
IF R < 0 GOTO FOUND
GOTO SWEEP
FOUND
0 - R TO R ; R = positive range to target
TRACK
IF R < 40 GOTO KILL ; close enough: open fire
GOSUB CHASE
PING
S TO RADAR ; still in the beam?
RADAR TO T
IF T < 0 GOTO HOLD
S - 6 TO RADAR ; nearby probes to reacquire
RADAR TO T
IF T < 0 GOTO LEFT
S + 6 TO RADAR
RADAR TO T
IF T < 0 GOTO RIGHT
GOTO LOOP ; lost it: stop and sweep again
HOLD
0 - T TO R
GOTO TRACK
LEFT
S - 6 TO S
GOTO HOLD
RIGHT
S + 6 TO S
GOTO HOLD
KILL
IF R > 24 GOTO AIMED ; never burst a shell on our own chassis
25 TO R
AIMED
S TO AIM
R TO SHOT
GOSUB CHASE ; keep bearing down on it
GOTO PING
CHASE ; set X/Y speeds toward bearing S
S TO G
GOSUB TENT
H + H TO SPEEDX ; speed x = 2 * tent(S)
S + 90 TO G
GOSUB TENT
0 - H - H TO SPEEDY ; speed y = -2 * tent(S + 90)
ENDSUB
TENT ; H = triangle wave of G (degrees):
; 0 -> 0, 90 -> 90, 180 -> 0, 270 -> -90.
; accepts G anywhere in -360..720
IF G < 0 GOTO TENTN
IF G < 360 GOTO TENTW
G - 360 TO G
GOTO TENTW
TENTN
G + 360 TO G
TENTW
IF G > 90 GOTO TENT2
G TO H
ENDSUB
TENT2
IF G > 270 GOTO TENT3
180 - G TO H
ENDSUB
TENT3
G - 360 TO H
ENDSUB