; Pea Shooter Ed T. Toton III 5/13/99 ; ; This robot is an example of a light-weight bot (it was specifically ; designed to fit into 32 lines of compiled code). Notice that it does ; not control it's own heat. Rather, the heat is regulated simply by ; using a wimpy weapon, and a slow-but-simple targetting calculation. ; Put it up against SDUCK to see it's collision avoidance in action. #config weapon=1 ; gives 1 point #config scanner=3 ; gives 2 points #config engine=4 ; consumes 2 points #config heatsinks=2 ; consumes a point #msg Watch your six! :) mov ax, 1 int 3 ; Keepshift on. !begin mov dx, 64 ; Set our scan arc to 64 degrees !start opo 11, 100 ; Throttle to 100% opo 17, dx ; Set arc to DX ipo 7, fx ; Scan for enemy cmp fx 2000 ja !decide ; No one found? Decide what to do !track ; Someone was found mov bx, dx ; BX = DX (dx is the scan width) mpy bx, @3 ; bx = scanwidth*accuracy sar bx, 1 ; bx = scanwidth*accuracy/2 opo 12, bx ; turn turret by that amount. cmp dx, 2 ; check scanwidth jbe !fire ; width<=2? then fire, otherwise tighten shr dx, 1 ; tighten scanwidth !fire opo 15, @3 ; Fire! ; Set course towards target mov bx, @1 ; get current desired heading ; (not actual heading) ipo 3, ax ; Get actual heading add ax, @2 ; And add to it our turret offset ; AX is now our new desired heading. cmp fx 120 ; Check our distance jae !turn ; Too close? If not, then steer straight add ax, 64 ; if so, veer off !turn and ax, 255 ; Fix ax into 0-255. sub ax, bx ; get number of degrees to turn. opo 14, ax ; turn! jmp !start ; start over ;Decides what to do if no one found !decide cmp dx 64 ; Compare scanwidth to 64 jae !flip ; If above, then flip shl dx 1 ; otherwise, widen arc jmp !start ; start over !flip opo 12 128 ; rotate turret 128 degrees (180). opo 14 8 ; Turn slightly ; jmp !start ; start over ;program starts over automatically when it runs past the end.