/* AI Bots II v2.07b sample driving program * * (The dumb) Jugglers of flags * */ #include "aibots.h" #include static int scandir,scanbot,scanrange; static int flagenemy; void movetoxy_ret(int,int); void movetoxy(int,int); void movetoxy_ret(int x,int y) { int x0,y0,dx,dy,dir,range,ismoving; getinfo(&x0,&y0,NULL,NULL,NULL,NULL); dx = x - x0; dy = y - y0; range = (int) sqrt(dx*dx +dy*dy); dir = (int) (atan2((float)dy,(float)dx)/M_PI*180.0); move(dir,range); } void movetoxy(int x,int y) { int ismoving = 1; movetoxy_ret(x,y); while(ismoving) { getinfo(NULL,NULL,&ismoving,NULL,NULL,NULL); scan(scandir,&scanbot,&scanrange); if(scanrange > 4 && scanrange <23) fire(scandir,scanrange); else scandir += 5; } } int main() { int ret,teamid,botid,range = 5; int x,y,x0,y0,fx,fy; int enemyid,ismoving; int nextbot; scandir = 0; ret = init("Jugglers"); botid = ret; a: hisflagpos(&fx,&fy); movetoxy_ret(fx,fy); ismoving = 1; while(ismoving) { getinfo(NULL,NULL,&ismoving,NULL,NULL,NULL); if(whohashisflag() != -1) { stop(); ismoving = 0; } scan(scandir,&scanbot,&scanrange); if(scanrange > 5 && scanrange < 22) fire(scandir,scanrange); else scandir += 5; } if(whohashisflag() == -1) goto a; if(botid %5 == 0) { movetoxy(50,20); movetoxy(50,20); } if(botid % 5 == 1) { movetoxy(55,14); movetoxy(55,14); } if(botid % 5 == 2) { movetoxy(54,5); movetoxy(54,5); } if(botid % 5 == 3) { movetoxy(45,5); movetoxy(45,5); } if(botid % 5 == 4) { movetoxy(43,14); movetoxy(43,14); } while(whohashisflag() != -1) { scan(scandir,&scanbot,&scanrange); if(scanrange > 5 && scanrange < 22) fire(scandir,scanrange); else scandir += 5; if(scanrange > 5 && scanrange < 22) fire(scandir,scanrange); else scandir += 5; nextbot = botid + 1; if(nextbot == 10) nextbot = 5; else if(nextbot == 5) nextbot = 0; if(whohashisflag() == botid) passflagto(nextbot); } goto a; }