# RELOADING TIME = TIME FOR 9 RADAR SCANS ang; # The angle at which scanning/shooting takes place function moveto(x,y) posx; # The x-coordinate of the position posy; # The y-coordinate of the position stat; # The status of the bot(damage) closvar; # Shoot only if distance is less than this dbot; # Stores the distance to the bot found ANGINC; # Step in which angle is increases while scanning {posx:=Locx(); # Setting the values posy:=Locy(); closvar:=160; ANGINC:=5; while(posx<>x | posy<>y) do # Run this function till specified position is not {goto(x,y); dbot:=radar(ang); if(dbot0) then {fire(ang); ang:=ang-45;}; # If bot is found then shoot if ang:=ang+ANGINC; if(ang>360) then ang:=ang-360; # Change the angle from 361 to 0 when circle is complete stat:=hit(); # See if collision took place if(stat=1) then # Collision took place from above so... {if(posx>234) then # Make sure taking evasive action won't run the bot into a wall. {moveto(posx-15, posy+15); moveto(posx-15, posy-30);} else {moveto(posx+15, posy+15); moveto(posx+15, posy-30); };# Took the evasive action by stepping Diagonally backwards and then moving the bot in front so far ahead to just cross the obstructing bot completely }; if(stat=3) then # Collision took place from below {if(posx>234) then {moveto(posx-15, posy-15); moveto(posx-15, posy+30);} else {moveto(posx+15,posy-15); moveto(posx+15,posy+30); }; }; if(stat=2) then {if(posy>174) then {moveto(posx-15, posy-15); moveto(posx+30, posy-15);} else {moveto(posx-15, posy+15); moveto(posx+30, posy+15); }; }; if(stat=4) then {if(posy<174) then {moveto(posx+15, posy+15); moveto(posx-30, posy+15);} else {moveto(posx+15,posy-15); moveto(posx-30,posy-15); }; }; posx:=Locx(); # Update the position posy:=Locy(); }; } function movetocc(tmquad) # pass 0 if you want it to find nearest corner. COR; # Distance to stay away and scan the corner from posx; posy; quad; # The quadrant to which we have to move (Shown below) nbf; # Number of bots found while scanning the corner canigo; # Counter to see the no. of times the scan is to be made at the corner if another bot was found dbot; # Stores distance of bot found at last scan gone; # Flag to see if the bot moved to a corner or not ANGINC; # Steps in which the angle is increased during scan stang; enang; {COR:=35; # Setting values ANGINC:=14; # Ideally angle can be 14.32 assuming the other bot is stationary. posx:=Locx(); posy:=Locy(); if((tmquad=0 & posx>=125 & posy<=95) | tmquad=1) then # Find the quadrant to move to. {quad:=1; # 2|1 stang:=225; # --- enang:=405; # 3|4 are the quadrants }; if((tmquad=0 & posx<125 & posy<95) | tmquad=2) then {quad:=2; stang:=135; enang:=315; }; if((tmquad=0 & posx<125 & posy>95) | tmquad=3) then {quad:=3; stang:=45; enang:=225; }; if((tmquad=0 & posx>125 & posy>95) | tmquad=4) then {quad:=4; stang:=315; enang:=495; }; #moveto(125,95); # Brings to center of the arena gone:=0; # Setting gone flag to 0....... NOTE 0 is FALSE AND non 0 is TRUE (according to me) while(gone=0) do # Continue till bot parks itself in a corner {canigo:=0; # Everytime the bot changes the corner to park in, re-initialise the canigo count while(canigo<3) do # Scan thrice before the corner to go to is changed {nbf:=0; # Set No. of bots found in scanning the whole corner to 0 if(quad=1) then moveto(250-COR,COR); # Different positions for different corners if(quad=2) then moveto(COR,COR); if(quad=3) then moveto(COR,190-COR); if(quad=4) then moveto(250-COR,190-COR); ang:=stang; while(ang<=enang) do {dbot:=radar(ang); if(dbot<>0) then # If bot found then - {nbf:=nbf+1; if(dbot>5) then # don't shoot if the bot is so close that the explosion will damage you {fire(ang); # Shoot as soon as found #if((!Trsx()<0 | !Trsy()>0) & quad=1) then nbf:=nbf+1; #If bot ain't trying to move from corner then nbot++ #if((!Trsx()>0 | !Trsy()>0) & quad=2) then nbf:=nbf+1; #if((!Trsx()>0 | !Trsy()<0) & quad=3) then nbf:=nbf+1; #if((!Trsx()<0 | !Trsy()<0) & quad=4) then nbf:=nbf+1; }; }; ang:=ang+ANGINC; }; if(nbf=0) then # If bot not found then move to corner {if(quad=1) then moveto(244,6); if(quad=2) then moveto(6,6); if(quad=3) then moveto(6,184); if(quad=4) then moveto(244,184); gone:=1; canigo:=100; # gone flag - true , throw out of canigo while loop }; # If a bot was found then..... if(nbf>0) then canigo:=canigo+1; # If bot found then do again till canigo > }; # Can I go ender if(canigo>=3) then {if(quad=4) then quad:=1 else quad:=quad+1; # change the quadrant to move to if(quad=1) then {stang:=225; enang:=405; }; if(quad=2) then {stang:=135; enang:=315; }; if(quad=3) then {stang:=45; enang:=225; }; if(quad=4) then {stang:=315; enang:=495; }; }; }; # Ender for gone } function relax() cor; # No. of corner posx; # Position X-coordinate posy; # Position Y-coordinate stang; # Angle to start scan from enang; # Angle to end scan at dbot; # Distance to bot if found INCANG; # Step to increase angle while scanning stopflag; # Flag to get out of relax mode stat; # present status/damage initstat; # Initial state(when first moved to corner) closest; # Distance to closest bot repairoff; # Flag to turn repairing off for rapid fire closvar; # Shoot only if bot found is closer than closvar ttclosest; # Closest bot in this run of while loop fireoff; # Flag to turn fire off for repairing rollback; # Angle to roll back radar once bot found {posx:=Locx(); posy:=Locy(); INCANG:=3; initstat:=damage(); closvar:=105; stopflag:=0; rollback:=8; closest:=316; if(posx=244 & posy=6) then {cor:=1; stang:=90; enang:=180;}; # Figure out if at a corner and then specify start and end scan angles if(posx=6 & posy=6) then {cor:=2; stang:=0; enang:=90;}; if(posx=6 & posy=184) then {cor:=3; stang:=270; enang:=360;}; if(posx=244 & posy=184) then {cor:=4; stang:=180; enang:=270;}; ang:=stang; while(stopflag=0) do # repeat till time to get out of relax mode(stopflag=1) { dbot:=radar(ang); if(dbot<>0) then # If bot found then {if(dbot210) then {repairoff:=0; closvar:=316; INCANG:=2; if(GetNumRobots()>2) then fireoff:=1; rollback:=0;}; # Here ideally INCANG should be 1.818 if nothing is to be missed. Assuming other bot to be standing or moving in direction of sweep. # If closest bot is further than 210 then -> My bot should repair after firing, fire at bot closer than 316, increase angle of scan by 2, should not rollback on firing and if No. of bots > 2 then shouldn't fire at all. if(closest <=210 & closest>105) then {repairoff:=0; closvar:=210; INCANG:=3; fireoff:=0; rollback:=27;}; # Ideally INCANG oughtta be 2.72 if nothing is to be missed. Assuming other bot to be standing or moving in direction of sweep. When closest bot between 105 and 210 then... My bot should repair after firing, shoot anything closer then 210, # increase angle of scan by 3, roll back 27 on firing (reload time oughtta be time for 3 scans) if(closest<=105) then {repairoff:=1; closvar:=105; INCANG:=6; fireoff:=0;rollback:=54;}; # Ideally INCANG oughtta be 5.45 if nothing is to be missed. Assuming other bot to be standing or moving in direction of sweep. If closest bot found is closer than 105 then... My bot should not go into repair after firing, fire at anything closer # than 105, increase angle of scan by 6, rollback 54 on firing (reload time oughhta be time for 4 scans) if(dbot<=closvar & fireoff=0) then {if(fire(ang)) then ang:=ang-rollback;}; # Fire and roll back stat:=hit(); # Find status of bot if(stat<5 & stat>0) then stopflag:=1; # Exit if blind ass is colliding with you if(repairoff=0 & stopflag<>1 & damage()<90) then repair(); # Repair if no blind ass collision and repair on stat:=hit(); # Find status of bot again if(stat<5 & stat>0) then stopflag:=1; # Exit if blind ass is colliding with you }; if( (initstat-damage()) > 30) then {stopflag:=1; if(cor=1) then stat:=3; # Exit if your health decreases by 30 in one corner. 2nd statement sets up a virtual blind ass colliding from stat direction because run needs 2 parameters if(cor=2) then stat:=2; if(cor=3) then stat:=1; if(cor=4) then stat:=4; }; #if( damage() < 15 ) then stopflag:=1; # If status becomes critically low then stop relaxing and use another strategy # End of if bot found ang:=ang+INCANG; # Increase angle by INCANG if(ang>enang) then {ttclosest:=316; closest:=ttclosest; ang:=stang;}; # At the end of one sweep -> Set ttclosest to max possible value. Set closest to ttclosest value found in last sweep, bring ang to starting angle if end angle is reached }; # End of while ( till my bot has to relax ) # if(damage()<=15) then critical(cor) else # Use critical strategy when health exceptionally low if(GetNumRobots()<>2) then run(cor,stat); # Run after exiting relax } function run(cor,stat) # Run function {if(cor=1 & stat=4) then # Blind ass hitting from direction and you are at corner {moveto(244,21); movetocc(4);}; # Move away from bot and then change corner if(cor=1 & stat=3) then {moveto(229,6); movetocc(2);}; if(cor=2 & stat=2) then {moveto(6,21); movetocc(3);}; if(cor=2 & stat=3) then {moveto(21,6); movetocc(1);}; if(cor=3 & stat=2) then {moveto(6,169); movetocc(2);}; if(cor=3 & stat=1) then {moveto(21,184); movetocc(4);}; if(cor=4 & stat=1) then {moveto(229,184); movetocc(3);}; if(cor=4 & stat=4) then {moveto(244,169); movetocc(1);}; } begin {movetocc(0); while(GetNumRobots()>1) do { relax(); }; } end