mirror of
https://github.com/richardharrington/robotwar.git
synced 2026-11-25 14:21:40 +00:00
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>
53 lines
1.4 KiB
Plaintext
53 lines
1.4 KiB
Plaintext
|
|
; CAMPER: races to the top-left corner so
|
|
; nothing can get behind it, then sweeps a
|
|
; 90-degree arc (east through south) in
|
|
; 3-degree steps, firing at contacts. At the
|
|
; end of each arc it checks it hasn't been
|
|
; knocked out of the corner.
|
|
|
|
15 TO A ; corner coordinates
|
|
15 TO B
|
|
4 TO RANDOM ; arc-phase jitter: reads give 0..3
|
|
|
|
MOVE
|
|
IF A # X GOSUB MOVEX ; recalibrate SPEEDX while off-target
|
|
TO N ; no-op else-branch
|
|
IF B # Y GOSUB MOVEY
|
|
IF A = X GOTO CAMP ; arrived: start sniping
|
|
GOTO MOVE
|
|
|
|
MOVEX
|
|
A - X TO SPEEDX
|
|
ENDSUB
|
|
|
|
MOVEY
|
|
B - Y TO SPEEDY
|
|
ENDSUB
|
|
|
|
CAMP
|
|
0 TO SPEEDX
|
|
0 TO SPEEDY
|
|
82 + RANDOM TO S ; sweep bearing, ~82..185 degrees;
|
|
; jittered phase so a distant stationary
|
|
; target can't hide between rays forever
|
|
|
|
SWEEP
|
|
S + 3 TO S
|
|
IF S > 185 GOTO RESET
|
|
S TO RADAR
|
|
RADAR TO R
|
|
IF R < 0 GOTO FIRE
|
|
GOTO SWEEP
|
|
|
|
RESET
|
|
82 + RANDOM TO S ; re-jitter the arc phase
|
|
IF A # X GOTO MOVE ; bumped out of the corner? go back
|
|
IF B # Y GOTO MOVE
|
|
GOTO SWEEP
|
|
|
|
FIRE
|
|
S TO AIM
|
|
0 - R TO SHOT
|
|
GOTO SWEEP
|