;Robot EHEU, programmed by Jude Hungerford. Work started on 1/11/2000. ;Last modified on 20/11/2000. ;Version 0.34 ;Modlist: ;Previous bits of modlist in their own file. Email me at ;lichen_dragon@my-deja.com if you want to see it. ;0.31 - 0.32: ;Start work on adjusting firing offsets for different speeds. ;Seems to work okay. ;I've done all of today's modifications stoned. ;0.32 - 0.33: ;try a different vehichle configuration. ;which failed, skipping 0.33. ;0.32 - 0.34: ;I've been running lots of big simulations. It looks like 0.23 is the most ;effective all-round version, which is very annoying. I would have preferred ;that it was 0.32, for obvious reasons. I'm now looking over the changelog ;to see what I've done since 0.23 that might make it worse. ;However, the difference isn't huge, so I'll probably just proceed from here. ;I think it might be because of the changes to the firing offsets. They've ;been kind of all over the place since version 0.24 and onwards, so I should ;fix that. First, however, I want to change the firing offset code so it ;decides which sort of offset to do based on actual robot speed instead of ;the robot's throttle. So that's the change for this version. ;That was a big improvement. It now beats 0.23 quite soundly. !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, 385 ;Firing offsets. put 0, 386 put 2, 387 put 4, 388 put 5, 389 put 5, 390 put 6, 391 put 6, 392 put 6, 393 put 7, 394 put 7, 395 put 6, 936 put 4, 397 put 2, 398 put 1, 399 put 0, 400 put 0, 401 put -1, 402 put -2, 403 put -4, 404 put -4, 405 put -5, 406 put -6, 407 put -6, 408 put -6, 409 put -6, 410 put -6, 411 put -6, 412 put -5, 413 put -3, 414 put -2, 415 put -1, 416 put 0 417 out 22, 7 ;lay mine, trigger 7. put 0, 418 ;slow positive. put 1, 419 put 2, 420 put 3, 421 put 3, 422 put 2, 423 put 1, 424 put 0, 425 put 0, 426 put -1, 427 put -2, 428 put -3, 429 put -3, 430 put -2, 431 put -1, 432 put 0, 433 put 0, 434 ;fast negative put -2, 435 put -4, 436 put -6, 437 put -6, 438 put -4, 439 put -2, 440 put 0, 441 put 0, 442 put 2, 443 put 4, 444 put 6, 445 put 6, 446 put 4, 447 put 2, 448 put 0, 449 put 0, 450 ;slow negative put -1, 451 put -2, 452 put -3, 453 put -3, 454 put -2, 455 put -1, 456 put 0, 457 put 0, 458 put 1, 459 put 2, 460 put 3, 461 put 3, 462 put 2, 463 put 1, 464 put 0, 465 !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 cmp @13, 300 ;target above 300 cm/cycle (normal max.400) ? jgr !pmovfiref ;yes, fire at fast target. jle !pmovfires ;no, fire at slow target. !pmovfiref mov bx, @6 ;BX=heading of enemy. shr bx, 3 ;bx/=8 add bx, 385 ;bx+=385 (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 !pmovfires mov bx, @6 ;BX=heading of enemy. shr bx, 4 ;bx/=16 add bx, 418 ;bx+=418 (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 cmp @13, -150 ;less than 150? jls !nmovfiref ;fire at fast backward target. jge !nmovfires ;fire at slow backward target. !nmovfiref mov bx, @6 ;BX=heading of enemy. shr bx, 4 ;bx/=16 add bx, 434 ;bx+=434 (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 !nmovfires mov bx, @6 ;BX=heading of enemy. shr bx, 4 ;bx/=16 add bx, 450 ;bx+=450 (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 !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.