mirror of
https://github.com/richardharrington/robotwar.git
synced 2026-11-26 09:22:43 +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>
43 lines
1.1 KiB
Plaintext
43 lines
1.1 KiB
Plaintext
|
|
; SWEEPER-LEAD: like sweeper, but after a
|
|
; contact it re-pings to see which way the
|
|
; target is drifting across the beam, and
|
|
; leads its shot in that direction.
|
|
|
|
0 TO S ; S = radar bearing
|
|
4 TO RANDOM ; jittered sweep step, see sweeper.rw
|
|
|
|
LOOP
|
|
S + 4 + RANDOM TO S ; advance the sweep 4..7 degrees
|
|
S TO RADAR
|
|
RADAR TO R
|
|
IF R < 0 GOTO CHECK
|
|
GOTO LOOP
|
|
|
|
CHECK
|
|
S TO RADAR ; re-ping the same bearing
|
|
RADAR TO T
|
|
IF T < 0 GOTO FIRE ; still in the beam: fire straight
|
|
S + 8 TO RADAR ; drifted ahead of the sweep?
|
|
RADAR TO T
|
|
IF T < 0 GOTO LEAD
|
|
S - 8 TO RADAR ; or behind it?
|
|
RADAR TO T
|
|
IF T < 0 GOTO LAG
|
|
GOTO LOOP ; lost it; resume the sweep
|
|
|
|
FIRE
|
|
S TO AIM
|
|
0 - T TO SHOT
|
|
GOTO LOOP
|
|
|
|
LEAD
|
|
S + 16 TO AIM ; aim past the drift and let it walk in
|
|
0 - T TO SHOT
|
|
GOTO LOOP
|
|
|
|
LAG
|
|
S - 16 TO AIM
|
|
0 - T TO SHOT
|
|
GOTO LOOP
|