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>
26 lines
1.1 KiB
Plaintext
26 lines
1.1 KiB
Plaintext
|
|
; SWEEPER: stands still and sweeps its radar
|
|
; in 5-degree steps. On contact (RADAR reads
|
|
; negative when a robot is in the beam), aims
|
|
; along the radar bearing and fires a shell
|
|
; timed to burst at the reported distance.
|
|
; S grows without bound; RADAR and AIM both
|
|
; wrap it mod 360 internally. The step is
|
|
; jittered so two stationary robots can't
|
|
; leave each other between rays forever.
|
|
|
|
0 TO S ; S = radar bearing
|
|
4 TO RANDOM ; RANDOM now reads as 0..3
|
|
|
|
LOOP
|
|
S + 4 + RANDOM TO S ; advance the sweep 4..7 degrees
|
|
S TO RADAR ; point the radar
|
|
RADAR TO R ; scan: negative means a robot at range -R
|
|
IF R < 0 GOTO FIRE
|
|
GOTO LOOP
|
|
|
|
FIRE
|
|
S TO AIM ; shoot along the radar bearing
|
|
0 - R TO SHOT ; burst right on the contact
|
|
GOTO LOOP
|