;Robot EHEU, programmed by Jude Hungerford. Work started on 1/11/2000. ;Last modified on 17/12/2000. ;Version 0.52 ;This robot owes ideas, but no direct code, to Warblade, Zitgun, JX19, and ;probably a whole host of other 'bots. ;Modlist: ;Previous bits of modlist in their own file. Email me at ;lichen_dragon@my-deja.com if you want to see it. ;0.49 - 0.50: ;Currently, it's normally "best marksman" but also "most conservative". I'd ;like to try to speed up the radar scanning code, and I might try to further ;improve the accuracy. ;I've improved the radar scan code. Firing adjustments for next version. ;0.50 - 0.51: ;Fire only 2 shots when enemy is found: heat is the limiting factor on how ;much I fire, so I may as well have the shots as accurate as possible. ;Like the last one, another fairly big improvement, it seems. ;0.51 - 0.52: ;experiments with new robot configurations. !init #config scanner= 5 #config weapon= 3 #config armor= 3 #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. ;Firing offsets: put 0, 385 ;Fast target. put 0, 386 put 2, 387 put 2, 388 put 4, 389 put 4, 390 put 5, 391 put 5, 392 put 6, 393 put 6, 394 put 6, 395 put 6, 396 put 6, 397 put 7, 398 put 7, 399 put 7, 400 put 0, 401 ;Upper-medium target. put 0, 402 put 2, 403 put 2, 404 put 3, 405 put 3, 406 put 3, 407 put 4, 408 put 4, 409 put 4, 410 put 4, 411 put 3, 412 put 3, 413 put 2, 414 put 1, 415 put 1, 416 put 0, 417 ;Lower-medium target. put 1, 418 put 1, 419 put 2, 420 put 2, 421 put 2, 422 put 2, 423 put 2, 424 put 2, 425 put 3, 426 put 4, 427 put 3, 428 put 2, 429 put 3, 430 put 2, 431 put 1, 432 put 0, 433 ;Slow target. put 1, 434 put 1, 435 put 1, 436 put 1, 437 put 1, 438 put 1, 439 put 1, 440 put 1, 441 put 2, 442 put 2, 443 put 2, 444 put 2, 445 put 2, 446 put 2, 447 put 2, 448 !path in 10, ax ;get random number. add ax, 32768 ;make positive. shr ax, 9 ;reduce to 0-64. add ax, 36 ;36-100. out 11, ax ;set throttle to random value. 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. ; add @9, 700 ;say we've travelled far. ; 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, 1 ;BX=25%DX out 12, BX ;turn radar right by 150% 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, 1 ;BX=DX/4 neg BX ;BX=-5dx/4 out 12, BX ;turn radar left by 150% scanarc. jmp !path ;path. !fire out 12, @3 ;correct turret. in 2, BX ;check heat. cmp BX, 200 ;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 cmp @13, 450 ;target above 400 cm/cycle (normal max.400) ? jgr !pmovfireff ;yes, fire at v. fast target. cmp @13, 250 ;250850? jgr !dwall ;if yes, respond to upward wall. Else: cmp ex, 150 ;ex<150? jls !lwall ;if yes, respond to left wall. Else: cmp ex, 850 ;ex>850? jgr !rwall ;if yes, respond to right 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 EX, 256 ;desired heading (-16). sub EX, @1 ;difference from current heading. add EX, 16 ;extra 16. out 14, EX ;turn by difference to desired heading. out 11, 100 ;forward, full throttle. jmp !scan ;return. !lwalll mov EX, 112 ;desired heading. sub EX, @1 ;difference from current heading. out 14, EX ;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 EX, 144 ;desired heading. sub EX, @1 ;difference from current heading. out 14, EX ;turn by difference to desired heading. out 11, 100 ;forward, full throttle. jmp !scan ;return. !rwalll mov EX, 0 ;desired heading. sub EX, @1 ;difference from current heading. sub EX, 16 ;-16 extra out 14, EX ;turn by difference to desired heading. out 11, 100 ;forward, full throttle. jmp !scan ;return. !dwall cmp @1, 64 ;error checking. jls !scan ;moving away anyway. cmp @1, 192 ;error checking. jgr !scan ;moving away anyway. 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 EX, 208 ;desired heading. sub EX, @1 ;difference from current heading. out 14, EX ;turn by difference to desired heading. out 11, 100 ;forward, full throttle. jmp !scan ;return. !dwalll mov EX, 48 ;desired heading. sub EX, @1 ;difference from current heading. out 14, EX ;turn by difference to desired heading. out 11, 100 ;forward, full throttle. jmp !scan ;return. !uwall cmp @1, 64 ;error checking. jls !uwall2 ;continue cmp @1, 192 ;error checking. jgr !uwall2 ;continue jmp !scan ;moving away anyway. !uwall2 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 EX, 80 ;desired heading. sub EX, @1 ;difference from current heading. out 14, EX ;turn by difference to desired heading. out 11, 100 ;forward, full throttle. jmp !scan ;return. !uwalll mov EX, 176 ;desired heading. sub EX, @1 ;difference from current heading. out 14, EX ;turn by difference to desired heading. out 11, 100 ;forward, full throttle. jmp !scan ;return. !fireadj ;adjusted firing routine. err bx ;show memory location of offset. out 12, cx ;move turret. out 15, 0 ;fire w/ new angle. out 15, 0 ;fire w/ new angle. jmp !lock