;Robot EHEU, programmed by Jude Hungerford. Work started on 1/11/2000. ;Last modified on 2/11/2000. ;Version 0.13 ;This program is in the public domain, but I'd appreciate it if you gave me ;credit if you derive anything interesting from it, or use any code from it, ;or ideas, or whatever. Also, please consider making your robot's source ;available to all of us, as I have. ;The 'bot takes ideas from Zitgun, Lynx, and probably a whole heap of other ;robots who I've watched fighting. The most obvious thing I've used from ;other robots is the scanning technique. ;notes on the robot: I'm starting out with a semi-hierarchical approach, but ;I find that doesn't work as well as I'd like with this game, so I might move ;to a more decentralised structure later. ;DX = scan width. ;I think I've written this robot's components in a better order than I have ;in the past. I think that going for movement, then radar, then gun is a good ;approach, because the effectiveness of the latter ones is dependent on ;having the former working well. A radar routine that works well mounted on ;a stationary robot may fail when the robot starts driving around. ;Modlist: ;Blank file - 0.001: ;write the movement routine. Basic movement: detect collisions and respond to ;them. If we've travelled x meters (685 at the present) since our last turn, ;make a right angle turn. ;0.001 - 0.002: ;write the scanning routine. ;I think I've done this wrongly. I need to fix the turret corrections for new ;scan arcs, and probably some structural things as well. The structure sucks, ;so I'll rewrite it soon. ;0.002 - 0.003 ;Well, the structure was really fucked. I didn't even call the new routines. ;I'll now do some restructuring to fix this. ;Damn, I fucked that up. Not only were the alterations bad, but I wrote over ;the previous file. Oh, well. Fixing things up... ;0.003 - 0.004 ;Right, I've fixed that error. Now I need to fix the scan arc/turret ;adjustments, and then I can write the firing routines. ;0.004 - 0.005 ;Hm... still haven't got the scanarc/turret routines right. I'll try ;increasing the correction by 25%. ;Damn. Once again, I saved over the old one. ;0.005 - 0.006 ;Write the firing routines. The scan routines aren't perfect, but some of the ;turret corrections have to be done from within the firing routines, so I'll ;just move on. ;0.006 - 0.007 ;Hm... the firing routine works a little differently from what I had ;expected. I forgot to account for overheating, so it overheats seriously. ;I'll fix this now. ;The firing accuracy is terrible. I'm going to try firing a spread of bullets ;and keeping the heat really low, see how this works. So I'll fire less ;frequently but hopefully hit a bit more. ;0.007 - 0.008 ;Still not much good. I'll try doubling the accuracy adjustments. ;0.008 - 0.009: ;I've tried a few tweaks, but they're not really working. I'll now try ;writing a routine solely dedicated to keeping narrow radar locks once I have ;them. ;0.009 - 0.010 ;That works. Next projects are to reduce the scan range and increase speed, ;do other config stuff, expand the firing routines to adjust for range, and ;reduce the priority given to the radar so that I don't forget to steer when ;I have a radar lock. Done. Also fixed a bug in !flip. ;0.010 - 0.011: ;Okay... I've just found out how Warblade does his firing accuracy ;adjustments. I never realised what the @6 system variable was, or how ;useful it was. Rather than redo all the calculations myself, I'm going to ;copy his. This 'bot owes a lot to Warblade now. I might do my own ;calculations sometime, see if I can improve on it. ;0.11 - 0.13: ;skipping 0.12 b/c it didn't work. !init #config scanner= 3 #config weapon= 2 #config armor= 3 #config engine= 3 #config heatsinks= 1 out 11, 100 ;full throttle. out 22, 7 ;lay mine, trigger 7. del 5 ;wait 5 cycles out 22, 7 ;lay mine, trigger 7. out 17, 64 ;128 degree scan arc. mov DX, 64 mov AX, 1 int 3 ;keepshift on. put 0 448 put 0 449 put 0 450 put 1 451 put 1 452 put 2 453 put 2 454 put 3 455 put 3 456 put 3 457 put 4 458 put 4 459 put 4 460 put 4 461 put 5 462 put 5 463 put 5 464 put 5 465 put 5 466 put 4 467 put 4 468 put 4 469 put 4 470 put 3 471 put 3 472 put 3 473 put 2 474 put 2 475 put 1 476 put 1 477 put 0 478 put 0 479 put 0 480 put -0 481 put -0 482 put -1 483 put -1 484 put -2 485 put -2 486 put -3 487 put -3 488 put -3 489 put -4 490 put -4 491 put -4 492 put -4 493 put -5 494 put -5 495 put -5 496 put -5 497 put -5 498 put -4 499 put -4 500 put -4 501 put -4 502 put -3 503 put -3 504 put -3 505 put -2 506 put -2 507 put -1 508 put -1 509 put -0 510 put -0 511 !path cmp @9, 685 ;Have we travelled 685 metres? jgr !steer ;if yes, steer. int 12 ;collisions? cmp FX, 0 jgr !crash ;if yes, respond to crash. jmp !scan !steer int 19 ;clear meters count. out 14, -64 ;turn 64 degrees left. jmp !path ;check steering again (for collisions) !crash out 11, -75 ;reverse del 5 ;wait 5. out 14, -32 ;turn 32 degrees left. out 11, 100 ;forward, full throttle. int 13 ;reset collision count. int 19 ;clear meters count. jmp !path ;check steering again. !scan in 7, BX ;scan cmp BX, 1500 ;anyone in sight? jge !nonefound ;adjust scan arc to suit. jls !arcmodf ;modify arc & fire. jmp !path ;path - will never be called. !nonefound cmp DX, 64 ;Are we at maximum scan width already? je !flip ;if yes, flip turret. shl DX, 1 ;else, double DX and out 17, DX ;set new scans to DX width. jmp !path ;path !flip out 12, 125 ;turn turret 125 degrees. jmp !path ;path !arcmodf cmp DX, 2 ;is scan angle 1 degree? je !fire ;if yes, fire. Else: shr DX, 1 ;halve DX out 17, DX ;set scans to DX. cmp @3, 0 ;is enemy in centre? jgr !accright ;if right, respond jls !accleft ;if left, respond. jmp !path ;else, path. !accright out 12, DX ;turn radar right by scanarc. cmp @3, 2 ;is it out by +2? jls !path ;if less, path. mov BX, DX ;Else: BX=DX shr BX, 2 ;BX=25%DX add BX, DX ;BX=125% DX out 12, BX ;turn radar right by 125% scanarc. jmp !path ;path. !accleft mov BX, DX ;set BX=scanarc neg BX ;and negate BX out 12, BX ;turn radar left by scanarc. cmp @3, -2 ;is it out by -2? jgr !path ;if more, path. neg BX ;Else: BX=DX shr BX, 2 ;BX=DX/4 add BX, DX ;BX=5DX/4 neg BX ;BX=-5dx/4 out 12, BX ;turn radar left by 125% scanarc. jmp !path ;path. !fire out 12, @3 ;correct turret. in 2, BX ;check heat. cmp BX, 100 ;too hot? jgr !lock ;if yes, lock. Else: cmp @7, 0 ;Is target stationary? je !statfire ;if yes, fire at stationary target. Else: jmp !movfire ;fire at moving target !statfire out 15, 0 ;fire out 15, 0 ;fire out 15, 0 ;fire out 15, 0 ;fire jmp !lock ;lock. !movfire mov bx, @6 ;BX=heading of enemy. shr bx, 2 ;bx/=4 add bx, 448 ;bx+=448 (for memory addressing) get bx, bx ;bx = contents of memory location bx. out 12, bx ;turn turret. out 15, 0 ;fire. out 15, 2 ;fire. out 15, -2 ;fire. jmp !lock !lock in 7, BX ;scan cmp @3, 0 ;is it dead centre? je !path ;if yes, return to path. Else: out 12, @3 ;adjust turret jmp !path ;and path.