; &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& ; &&& ACE BOT v1 &&& ; &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& ; ; Writer: Georg Schnabel (aka GreatGeorge) ; Email: georg.schnabel@mycity.at ; ; This is my first real standard class bot ; and i hope when you read this, it will ; be in the top 5 :-) ; ; CURRENT FEATURES: ; - nice target prediction ; - don't go near walls ; - intelligent scanning routine ; ; I want that everybody who wants to get ; better in AT-Robots can learn from my ; code, so it is well commented ... ; ; If you have have any ideas how to further ; improve this bot you can tell me :-) ; [E N J O Y] ; ------------------------------------------ #config scanner=3 #config weapon=3 #config heatsinks=1 #config engine=3 #config armor=2 #def RANGE ; -> needed for target prediction #def SCANARC #def SPEED ; -> stores the speed of the robot #msg I'm an ace :-) jmp !SETUP ; ******************************************* ; ; - PREDICTION TABLE - ; ; ******************************************* ; ; So this is my prediction table :-) ; It is 500 lines long and there are 2048 ; values in it. If necessary you can even ; store 4096 values because the turret dis- ; placement never becomes a value greater than ; 255, so we can pack two values in one number ; Scary huh :-) ; ; here's the formula i used: ; ; BotDsp = Spd * Dst / (3200 * Wmod) ; Offset = sin^-1[BotDsp * sin Ang / sqrt(BotDsp^2 + Dst^2 - 2 * BotDsp * Dst * cos Ang)] ; ; Wmod ... weapon multiplier (if weapon got 3 points then multiplier is 1.20) ; Spd ... speed of enemy ; Dst ... distance to enemy ; Ang ... relative angle of enemy to scan ; BotDsp ... scaled speed dependend on distance and weapon speed *256, 256, 256, 256 *256, 256, 256, 256 *256, 256, 256, 256 *256, 256, 256, 256 *256, 256, 256, 257 *256, 256, 256, 256 *256, 256, 256, 256 *255, 256, 256, 256 *256, 256, 256, 267 *257, 256, 256, 256 *256, 256, 256, 255 *245, 256, 256, 256 *256, 256, 256, 256 *258, 257, 256, 256 *256, 256, 255, 254 *256, 256, 256, 256 *256, 256, 256, 256 *258, 257, 256, 256 *256, 256, 255, 254 *256, 256, 256, 256 *256, 256, 256, 256 *258, 257, 256, 256 *256, 256, 255, 254 *256, 256, 256, 256 *256, 256, 256, 256 *258, 257, 256, 256 *256, 256, 255, 254 *256, 256, 256, 256 *256, 256, 256, 256 *259, 257, 256, 256 *256, 256, 255, 253 *256, 256, 256, 256 *256, 256, 256, 256 *259, 257, 257, 256 *256, 255, 255, 253 *256, 256, 256, 256 *256, 256, 256, 256 *259, 258, 257, 256 *256, 255, 254, 253 *256, 256, 256, 256 *256, 256, 256, 256 *260, 258, 257, 256 *256, 255, 254, 252 *256, 256, 256, 256 *256, 256, 256, 256 *260, 258, 257, 256 *256, 255, 254, 252 *256, 256, 256, 256 *256, 256, 256, 256 *260, 258, 257, 256 *256, 255, 254, 252 *256, 256, 256, 256 *256, 256, 256, 256 *260, 258, 257, 256 *256, 255, 254, 252 *256, 256, 256, 256 *256, 256, 256, 256 *261, 258, 257, 256 *256, 255, 254, 251 *256, 256, 256, 256 *256, 256, 256, 256 *261, 258, 257, 256 *256, 255, 254, 251 *256, 256, 256, 256 *256, 256, 256, 256 *256, 256, 256, 256 *256, 256, 256, 256 *256, 256, 256, 256 *257, 257, 257, 257 *257, 256, 256, 256 *256, 256, 256, 255 *255, 255, 255, 255 *256, 256, 262, 258 *257, 257, 256, 256 *256, 256, 255, 255 *254, 250, 256, 256 *256, 256, 256, 260 *258, 257, 257, 256 *256, 255, 255, 254 *252, 256, 256, 256 *256, 256, 256, 262 *259, 258, 257, 256 *256, 255, 254, 253 *250, 256, 256, 256 *256, 256, 256, 265 *259, 258, 257, 256 *256, 255, 254, 253 *247, 256, 256, 256 *256, 256, 256, 270 *260, 258, 257, 256 *256, 255, 254, 252 *242, 256, 256, 256 *256, 256, 256, 288 *260, 258, 257, 256 *256, 255, 254, 252 *224, 256, 256, 256 *256, 256, 256, 256 *261, 259, 257, 256 *256, 255, 253, 251 *256, 256, 256, 256 *256, 256, 256, 256 *261, 259, 257, 256 *256, 255, 253, 251 *256, 256, 256, 256 *256, 256, 256, 256 *262, 259, 258, 256 *256, 254, 253, 250 *256, 256, 256, 256 *256, 256, 256, 256 *262, 259, 258, 256 *256, 254, 253, 250 *256, 256, 256, 256 *256, 256, 256, 256 *262, 259, 258, 256 *256, 254, 253, 250 *256, 256, 256, 256 *256, 256, 256, 256 *263, 260, 258, 256 *256, 254, 252, 249 *256, 256, 256, 256 *256, 256, 256, 256 *263, 260, 258, 256 *256, 254, 252, 249 *256, 256, 256, 256 *256, 256, 256, 256 *264, 260, 258, 256 *256, 254, 252, 248 *256, 256, 256, 256 *256, 256, 256, 256 *256, 256, 256, 256 *256, 256, 256, 256 *256, 256, 256, 256 *256, 256, 257, 257 *257, 256, 256, 256 *256, 256, 256, 255 *255, 255, 256, 256 *258, 259, 258, 258 *258, 257, 256, 256 *256, 256, 255, 254 *254, 254, 253, 254 *256, 256, 261, 259 *258, 257, 257, 256 *256, 255, 255, 254 *253, 251, 256, 256 *256, 256, 296, 260 *259, 258, 257, 256 *256, 255, 254, 253 *252, 216, 256, 256 *256, 256, 256, 262 *260, 258, 257, 256 *256, 255, 254, 252 *250, 256, 256, 256 *256, 256, 256, 264 *260, 259, 257, 256 *256, 255, 253, 252 *248, 256, 256, 256 *256, 256, 256, 266 *261, 259, 258, 256 *256, 254, 253, 251 *246, 256, 256, 256 *256, 256, 256, 268 *261, 259, 258, 256 *256, 254, 253, 251 *244, 256, 256, 256 *256, 256, 256, 272 *262, 260, 258, 256 *256, 254, 252, 250 *240, 256, 256, 256 *256, 256, 256, 276 *262, 260, 258, 256 *256, 254, 252, 250 *236, 256, 256, 256 *256, 256, 256, 283 *263, 260, 258, 256 *256, 254, 252, 249 *229, 256, 256, 256 *256, 256, 256, 298 *263, 260, 258, 256 *256, 254, 252, 249 *214, 256, 256, 256 *256, 256, 256, 256 *264, 261, 258, 256 *256, 254, 251, 248 *256, 256, 256, 256 *256, 256, 256, 256 *264, 261, 259, 257 *255, 253, 251, 248 *256, 256, 256, 256 *256, 256, 256, 256 *265, 261, 259, 257 *255, 253, 251, 247 *256, 256, 256, 256 *256, 256, 256, 256 *256, 256, 256, 256 *256, 256, 256, 256 *256, 256, 256, 256 *256, 256, 257, 257 *257, 257, 256, 256 *256, 256, 255, 255 *255, 255, 256, 256 *256, 257, 258, 258 *258, 257, 256, 256 *256, 256, 255, 254 *254, 254, 255, 256 *259, 260, 259, 259 *258, 258, 257, 256 *256, 255, 254, 254 *253, 253, 252, 253 *256, 256, 262, 260 *259, 258, 257, 256 *256, 255, 254, 253 *252, 250, 256, 256 *256, 256, 267, 261 *260, 259, 257, 256 *256, 255, 253, 252 *251, 245, 256, 256 *256, 256, 256, 263 *261, 259, 258, 256 *256, 254, 253, 251 *249, 256, 256, 256 *256, 256, 256, 264 *261, 259, 258, 256 *256, 254, 253, 251 *248, 256, 256, 256 *256, 256, 256, 266 *262, 260, 258, 256 *256, 254, 252, 250 *246, 256, 256, 256 *256, 256, 256, 268 *262, 260, 258, 256 *256, 254, 252, 250 *244, 256, 256, 256 *256, 256, 256, 270 *263, 260, 258, 256 *256, 254, 252, 249 *242, 256, 256, 256 *256, 256, 256, 272 *264, 261, 259, 257 *255, 253, 251, 248 *240, 256, 256, 256 *256, 256, 256, 275 *264, 261, 259, 257 *255, 253, 251, 248 *237, 256, 256, 256 *256, 256, 256, 278 *265, 261, 259, 257 *255, 253, 251, 247 *234, 256, 256, 256 *256, 256, 256, 281 *265, 262, 259, 257 *255, 253, 250, 247 *231, 256, 256, 256 *256, 256, 256, 286 *266, 262, 259, 257 *255, 253, 250, 246 *226, 256, 256, 256 *256, 256, 256, 256 *256, 256, 256, 256 *256, 256, 256, 256 *256, 256, 256, 256 *256, 256, 257, 257 *257, 257, 256, 256 *256, 256, 255, 255 *255, 255, 256, 256 *256, 257, 258, 258 *258, 257, 257, 256 *256, 255, 255, 254 *254, 254, 255, 256 *257, 259, 259, 259 *258, 258, 257, 256 *256, 255, 254, 254 *253, 253, 253, 255 *260, 261, 261, 260 *259, 258, 257, 256 *256, 255, 254, 253 *252, 251, 251, 252 *256, 256, 263, 261 *260, 259, 257, 256 *256, 255, 253, 252 *251, 249, 256, 256 *256, 256, 266, 262 *261, 259, 258, 256 *256, 254, 253, 251 *250, 246, 256, 256 *256, 256, 274, 264 *261, 260, 258, 256 *256, 254, 252, 251 *248, 238, 256, 256 *256, 256, 256, 265 *262, 260, 258, 256 *256, 254, 252, 250 *247, 256, 256, 256 *256, 256, 256, 267 *263, 260, 258, 256 *256, 254, 252, 249 *245, 256, 256, 256 *256, 256, 256, 268 *263, 261, 259, 257 *255, 253, 251, 249 *244, 256, 256, 256 *256, 256, 256, 270 *264, 261, 259, 257 *255, 253, 251, 248 *242, 256, 256, 256 *256, 256, 256, 271 *265, 261, 259, 257 *255, 253, 251, 247 *241, 256, 256, 256 *256, 256, 256, 273 *265, 262, 259, 257 *255, 253, 250, 247 *239, 256, 256, 256 *256, 256, 256, 275 *266, 262, 259, 257 *255, 253, 250, 246 *237, 256, 256, 256 *256, 256, 256, 278 *266, 262, 260, 257 *255, 252, 250, 246 *234, 256, 256, 256 *256, 256, 256, 256 *256, 256, 256, 256 *256, 256, 256, 256 *256, 256, 256, 256 *256, 256, 257, 257 *257, 257, 256, 256 *256, 256, 255, 255 *255, 255, 256, 256 *256, 257, 258, 258 *258, 257, 257, 256 *256, 255, 255, 254 *254, 254, 255, 256 *257, 258, 259, 259 *258, 258, 257, 256 *256, 255, 254, 254 *253, 253, 254, 255 *257, 260, 260, 260 *259, 258, 257, 256 *256, 255, 254, 253 *252, 252, 252, 255 *261, 262, 262, 261 *260, 259, 258, 256 *256, 254, 253, 252 *251, 250, 250, 251 *256, 273, 264, 262 *261, 259, 258, 256 *256, 254, 253, 251 *250, 248, 239, 256 *256, 256, 267, 263 *262, 260, 258, 256 *256, 254, 252, 250 *249, 245, 256, 256 *256, 256, 271, 265 *262, 260, 258, 256 *256, 254, 252, 250 *247, 241, 256, 256 *256, 256, 282, 266 *263, 261, 259, 257 *255, 253, 251, 249 *246, 230, 256, 256 *256, 256, 256, 267 *264, 261, 259, 257 *255, 253, 251, 248 *245, 256, 256, 256 *256, 256, 256, 269 *264, 261, 259, 257 *255, 253, 251, 248 *243, 256, 256, 256 *256, 256, 256, 270 *265, 262, 259, 257 *255, 253, 250, 247 *242, 256, 256, 256 *256, 256, 256, 272 *265, 262, 259, 257 *255, 253, 250, 247 *240, 256, 256, 256 *256, 256, 256, 273 *266, 263, 260, 257 *255, 252, 249, 246 *239, 256, 256, 256 *256, 256, 256, 275 *267, 263, 260, 257 *255, 252, 249, 245 *237, 256, 256, 256 *256, 256, 256, 256 *256, 256, 256, 256 *256, 256, 256, 256 *256, 256, 256, 256 *256, 256, 257, 257 *257, 257, 256, 256 *256, 256, 255, 255 *255, 255, 256, 256 *256, 257, 258, 258 *258, 257, 257, 256 *256, 255, 255, 254 *254, 254, 255, 256 *256, 258, 259, 259 *259, 258, 257, 256 *256, 255, 254, 253 *253, 253, 254, 256 *257, 259, 260, 260 *259, 258, 257, 256 *256, 255, 254, 253 *252, 252, 253, 255 *258, 261, 261, 261 *260, 259, 258, 256 *256, 254, 253, 252 *251, 251, 251, 254 *261, 263, 263, 262 *261, 259, 258, 256 *256, 254, 253, 251 *250, 249, 249, 251 *256, 270, 265, 263 *262, 260, 258, 256 *256, 254, 252, 250 *249, 247, 242, 256 *256, 256, 267, 264 *262, 260, 259, 257 *255, 253, 252, 250 *248, 245, 256, 256 *256, 256, 271, 266 *263, 261, 259, 257 *255, 253, 251, 249 *246, 241, 256, 256 *256, 256, 277, 267 *264, 261, 259, 257 *255, 253, 251, 248 *245, 235, 256, 256 *256, 256, 290, 268 *264, 262, 259, 257 *255, 253, 250, 248 *244, 222, 256, 256 *256, 256, 256, 269 *265, 262, 259, 257 *255, 253, 250, 247 *243, 256, 256, 256 *256, 256, 256, 271 *266, 262, 260, 257 *255, 252, 250, 246 *241, 256, 256, 256 *256, 256, 256, 272 *266, 263, 260, 257 *255, 252, 249, 246 *240, 256, 256, 256 *256, 256, 256, 273 *267, 263, 260, 257 *255, 252, 249, 245 *239, 256, 256, 256 *256, 256, 256, 256 *256, 256, 256, 256 *256, 256, 256, 256 *256, 256, 256, 256 *256, 256, 257, 257 *257, 257, 256, 256 *256, 256, 255, 255 *255, 255, 256, 256 *256, 257, 258, 258 *258, 257, 257, 256 *256, 255, 255, 254 *254, 254, 255, 256 *256, 258, 259, 259 *259, 258, 257, 256 *256, 255, 254, 253 *253, 253, 254, 256 *257, 259, 260, 260 *259, 258, 257, 256 *256, 255, 254, 253 *252, 252, 253, 255 *257, 260, 261, 261 *260, 259, 258, 256 *256, 254, 253, 252 *251, 251, 252, 255 *258, 262, 262, 262 *261, 260, 258, 256 *256, 254, 252, 251 *250, 250, 250, 254 *262, 264, 264, 263 *262, 260, 258, 256 *256, 254, 252, 250 *249, 248, 248, 250 *256, 270, 266, 264 *262, 261, 259, 257 *255, 253, 251, 250 *248, 246, 242, 256 *256, 256, 268, 265 *263, 261, 259, 257 *255, 253, 251, 249 *247, 244, 256, 256 *256, 256, 271, 266 *264, 262, 259, 257 *255, 253, 250, 248 *246, 241, 256, 256 *256, 256, 275, 268 *265, 262, 259, 257 *255, 253, 250, 247 *244, 237, 256, 256 *256, 256, 282, 269 *265, 262, 260, 257 *255, 252, 250, 247 *243, 230, 256, 256 *256, 256, 296, 270 *266, 263, 260, 257 *255, 252, 249, 246 *242, 216, 256, 256 *256, 256, 256, 271 *266, 263, 260, 257 *255, 252, 249, 246 *241, 256, 256, 256 *256, 256, 256, 273 *267, 264, 260, 257 *255, 252, 248, 245 *239, 256, 256, 256 ; ***************************************** ; ; - ROBOTS PROGRAM - ; ; ***************************************** ; !SETUP opo P_MINELAYER, 20 ; lay two mines opo P_MINELAYER, 20 mov SPEED, 75 ; set speed var to 75 mov ax, 1 int I_KEEPSHIFT ; keepshift on !SEARCH cmp [0], 100 ; is speed at max? jeq !NOACC opo P_THROTTLE, 100 ; no -> accelerate !NOACC int I_LOCATE ; get position of robot cmp ex, 100 ; ex = x : fx = y jb !LWALL cmp ex, 900 ; check if robot is to near ja !RWALL ; by a wall cmp fx, 100 jb !UWALL cmp fx, 900 ja !DWALL jbe !RNDMOVE !LWALL cmp [1], 128 ; he is: is he facing to the wall too? jb !RNDMOVE opo P_STEERING, 32 ; yes: then turn slightly and check again jae !LWALL !RWALL cmp [1], 128 ; the same as for the left wall ja !RNDMOVE opo P_STEERING, 32 jbe !RWALL !UWALL mov dx, [1] ; here we have to rotate the add dx, 64 ; angles 64 degrees to the right and dx, 255 ; and "AND" it with 255 to make sure that the number cmp dx, 128 ; remains in 0-255; so we need only one cmp check ja !RNDMOVE opo P_STEERING, 32 jbe !UWALL !DWALL mov dx, [1] ; the same as for the top wall add dx, 64 and dx, 255 cmp dx, 128 jb !RNDMOVE opo P_STEERING, 32 jae !DWALL !RNDMOVE ; do nothing !FLIP ipo P_RADAR, RANGE ; is target in range? cmp RANGE, 700 ja !SEARCH ; no: jump to !SEARCH cmp [0], 100 ; no we have found a target reduce throttle jne !NOSPDCHG ; to SPEED, either -75 or 75 opo P_THROTTLE, SPEED !NOSPDCHG mov SCANARC, 64 ; set SCANARC to maximum opo P_TROTATE, 128 ; rotate turret !SCAN opo P_ARC, SCANARC ; now send the new SCANARC to the P_ARC port !NOSHR cmp [0], 0 jne !NOSPDINV neg SPEED opo P_THROTTLE, SPEED !NOSPDINV ipo P_SCAN, RANGE ; scan for enemy cmp RANGE, 700 jb !SHRINK cmp SCANARC, 64 ; not found: is scanarc already 64 (max) ? jae !FLIP ; yes, jump to !FLIP shl SCANARC, 1 ; no: widen scanarc (*2) jb !SCAN ; and scan again !SHRINK cmp SCANARC, 2 ; is scanarc less or equal then 2? jbe !FIRE ; yes: then jump to !FIRE cmp @3, -1 ; no: center enemy jls !NAcc2 jeq !NAcc1 cmp @3, 1 jeq !PAcc1 jgr !PAcc2 shr SCANARC, 2 ; already in center, than divide scanarc by 4 jne !SCAN !NAcc2 mov dx, SCANARC ; otherwise: divide only by 2 and center enemy neg dx opo P_TROTATE, dx shr SCANARC, 1 jls !SetDir !NAcc1 shr SCANARC, 1 mov dx, SCANARC neg dx opo P_TROTATE, dx jeq !SetDir !PAcc1 shr SCANARC, 1 opo P_TROTATE, SCANARC jeq !SetDir !PAcc2 opo P_TROTATE, SCANARC shr SCANARC, 1 jgr !SetDir !SetDir ; now ensure that enemy is perpendicular mov bx, @1 ; to AceBot add bx, 64 ipo P_COMPASS, ax add ax, @2 and ax, 255 sub ax, bx opo P_STEERING, ax jeq !SCAN ; jump to !SCAN jne !SCAN !FIRE ipo P_HEAT, ax ; is robot too hot? cmp ax, 150 ja !NOSHR ; yes: just center robot again mov ex, @13 ; no: generate an index in the prediction mov fx, @6 ; table with @13 (Spd), @6 (Ang) and range cmp ex, 0 ; if speed is negative... ja !cpred neg ex ; negate speed add fx, 128 ; and add 128 to angle and fx, 255 !cpred mov ax, fx ; spd flag sar RANGE, 7 sar ex, 6 sar fx, 4 sal RANGE, 8 sal ex, 4 mov dx, 1028 add dx, RANGE add dx, ex add dx, fx opo P_TROTATE, [dx] cmp ax, 640 ; robot very fast? ja !spreadfire ; yes: only spread fire opo P_FIRE, @3 opo P_FIRE, @3 opo P_FIRE, @3 jeq !NOSHR ; center enemy again jne !NOSHR !spreadfire opo P_FIRE, -2 opo P_FIRE, @3 opo P_FIRE, 2 jeq !NOSHR jne !NOSHR