;Robot EHEU, programmed by Jude Hungerford. Work started on 1/11/2000. ;Last modified on 20/11/2000. ;Version 0.31 ;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: ;0.20 - 0.21: ;I've moved the modlist to its own file. If you want to see it, contact me at ;lichen_dragon@my-deja.com ;0.21 - 0.22: ;Experimental: Try improving the !path driving code by making it drive ;roughly perpendicular to the turret- it handles firing offsets well, many ;'bots don't. ;0.22 - 0.23: ;That last change worked well, but I don't really know what it did, because I ;was confused... I'ts most frustrating. It seems to make it get stuck on ;walls more, and it seems to do well when stopped. I don't know why it would. ;For this version, I'm taking its speed right down and putting the points on ;other things, to see how it does. I'm also removing the extra movement code ;because I don't know what it did. ;Well, that worked really well. It's kind of annoying, because it means I ;have to change my perception of what kind of robot works best. :) It looks ;like the slow-moving tank could be the way to go. The movement and firing ;offset sections still need rewriting and tweaking respectively, but this ;has worked really well. I think it may be because the other robots assume ;you're moving at 100% speed or higher, and so it throws out their firing ;offsets by quite a way. Lynx still copes well, and so I think it may have ;some code to consider speed of the target beyond stationary/moving. I think ;I might look into including such code in mine sometime. Hm... there's lots ;of work to be done. I can easily see myself writing too much code and ;slowing the thing down too much. At least I have things to do with it now. ;) ;0.23 - 0.24: ;tweaking the firing offsets, targeting Lynx. ;Minor improvement, more work needed. ;0.24 - 0.25 ;I've just found a copy of the Sweeper that you fight against in the online ;battles. It's not the one currently in the database. It moves backwards. ;Small change this version to correct this: negate firing offset if target ;has negative velocity. ;0.25 - 0.26: ;add !checkpos code to steer according to position. ;0.26 - 0.27 ;That was a failure, but I think the principle is sound. I think I need to ;fix a couple of things. That's what I'm doing here. ;Better... more work needed. Trying something which means lots of changing, ;so I'm moving to a new version... ;which failed. 0.28 will be skipped because it didn't work. Still trying to ;fix the steering code. ;Success at last! Found and removed all the errors (I hope). ;Success... and it turns out to be worse than 0.25. I think this is because ;it's slowing it down too much. Only calling the !checkpos routine once it's ;crashed makes it better than 0.25. That's what I've done. And for the next ;version: ;0.27 - 0.29: ;revert to the old structure, but with the new !checkpos driving routines ;substituted into the old meters and collision responses. ;Done. Almost exactly as good as 0.27, and I think this is better, so I'll ;keep it. Maybe I should tweak the boundaries in which I'll turn? I'll play ;with that later. The next planned change is to include code that adjusts ;the firing offsets according to velocity of the target. ;I've stuffed something up with the numbering, so the next version will be ;0.31. !init #config scanner= 3 #config weapon= 4 #config armor= 4 #config engine= 0 #config heatsinks= 1 out 11, 100 ;full throttle. out 22, 7 ;lay mine, trigger 7. out 17, 64 ;128 degree scan arc. mov DX, 64 mov AX, 1 int 3 ;keepshift on. #def EL put 0, 400 ;Firing offsets. put 0, 401 put 2, 402 put 4, 403 put 5, 404 put 5, 405 put 6, 406 put 6, 407 put 6, 408 put 7, 409 put 7, 410 put 6, 411 put 4, 412 put 2, 413 put 1, 414 put 0, 415 put 0, 416 put -1, 417 put -2, 418 put -4, 419 put -4, 420 put -5, 421 put -6, 422 put -6, 423 put -6, 424 put -6, 425 put -6, 426 put -6, 427 put -5, 428 put -3, 429 put -2, 430 put -1, 431 put 0 432 out 22, 7 ;lay mine, trigger 7. !path cmp @9, 200 ;Have we travelled 200 metres? jgr !steer ;if yes, steer. int 12 ;collisions? cmp FX, 0 jgr !crash ;if yes, respond to crash. jmp !scan !crash out 11, -75 ;reverse int 13 ;reset collision count. jmp !checkpos ;determine where to go. !steer int 19 ;clear meters count. jmp !checkpos ;steer. !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, 120 ;too hot? jgr !lock ;if yes, lock. Else: cmp @7, 0 ;Is target stationary? je !statfire ;if yes, fire at stationary target. Else: jgr !pmovfire ;if moving forward, fire forwards of target. jls !nmovfire ;if moving backward, fire backward of target. !statfire mov AX, 1 ; int 4 ;Overburn= on. out 15, 0 ;fire out 15, 0 ;fire out 15, 0 ;fire out 15, 0 ;fire mov AX, 0 ; int 4 ;Overburn = off. jmp !lock ;lock. !pmovfire mov bx, @6 ;BX=heading of enemy. shr bx, 3 ;bx/=8 ; err bx ;show bx add bx, 400 ;bx+=400 (for memory addressing) get bx, bx ;bx = contents of memory location bx. out 12, bx ;move turret. out 15, 0 ;fire w/ new angle. out 15, 0 ;fire w/ new angle. out 15, 0 ;fire w/ new angle. jmp !lock !nmovfire mov bx, @6 ;BX=heading of enemy. shr bx, 3 ;bx/=8 ; err bx ;show bx add bx, 400 ;bx+=400 (for memory addressing) get bx, bx ;bx = contents of memory location bx. neg bx ;negate bx. out 12, bx ;move turret. out 15, 0 ;fire w/ new angle. out 15, 0 ;fire w/ new angle. out 15, 0 ;fire w/ new angle. 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. !checkpos int 2 ;get x and y co-ordinates. cmp ex, 250 ;ex<250? jls !lwall ;if yes, respond to left wall. Else: cmp ex, 750 ;ex>750? jgr !rwall ;if yes, respond to right wall. Else: cmp fx, 250 ;fx<250? jls !uwall ;if yes, respond to downward wall. Else: cmp fx, 750 ;fx>750? jgr !dwall ;if yes, respond to upward wall. Else: jmp !scan ;return. !lwall cmp @1, 128 ;error checking jls !scan ;robot was moving away anyway. cmp @1, 192 ;Is tank heading up or down oblique to wall? jgr !lwallr ;If up, turn right. Else: jle !lwalll ;down, turn left. !lwallr mov EL, 256 ;desired heading (-16). sub EL, @1 ;difference from current heading. add EL, 16 ;extra 16. out 14, EL ;turn by difference to desired heading. out 11, 100 ;forward, full throttle. ; err @1 jmp !scan ;return. !lwalll mov EL, 112 ;desired heading. sub EL, @1 ;difference from current heading. out 14, EL ;turn by difference to desired heading. out 11, 100 ;forward, full throttle. jmp !scan ;return. !rwall cmp @1, 128 ;error checking jgr !scan ;robot was moving away anyway. cmp @1, 64 ;Is tank heading up or down oblique to wall? jgr !rwallr ;If up, turn right. Else: jle !rwalll ;down, turn left. !rwallr mov EL, 144 ;desired heading. sub EL, @1 ;difference from current heading. out 14, EL ;turn by difference to desired heading. out 11, 100 ;forward, full throttle. jmp !scan ;return. !rwalll mov EL, 0 ;desired heading. sub EL, @1 ;difference from current heading. sub EL, 16 ;-16 extra out 14, EL ;turn by difference to desired heading. out 11, 100 ;forward, full throttle. ; err @1 jmp !scan ;return. !dwall cmp @1, 128 ;Is tank heading r/l oblique to wall? jgr !dwallr ;If right, turn right. Else: jle !dwalll ;left, turn left. !dwallr mov EL, 208 ;desired heading. sub EL, @1 ;difference from current heading. out 14, EL ;turn by difference to desired heading. out 11, 100 ;forward, full throttle. jmp !scan ;return. !dwalll mov EL, 48 ;desired heading. sub EL, @1 ;difference from current heading. out 14, EL ;turn by difference to desired heading. out 11, 100 ;forward, full throttle. jmp !scan ;return. !uwall cmp @1, 128 ;Is tank heading r/l oblique to wall? jge !uwalll ;If l, turn l. Else: jle !uwallr ;r, turn r. jmp !uwallr ;else, left. !uwallr mov EL, 80 ;desired heading. sub EL, @1 ;difference from current heading. out 14, EL ;turn by difference to desired heading. out 11, 100 ;forward, full throttle. jmp !scan ;return. !uwalll mov EL, 176 ;desired heading. sub EL, @1 ;difference from current heading. out 14, EL ;turn by difference to desired heading. out 11, 100 ;forward, full throttle. jmp !scan ;return.