X-Git-Url: http://royale.zerezo.com/git/?p=zeRace;a=blobdiff_plain;f=bot_anticip.c;h=424e8758754e6ff9e73e88f90f602045fcb05549;hp=22de8dde0e6a79a197172d9e994ab61a5e531c87;hb=1be6de5da72b6218e87c20e29782ce6f9d99196e;hpb=ee6ec6d95d78f74973a2ba97077cc94709bb6c61 diff --git a/bot_anticip.c b/bot_anticip.c index 22de8dd..424e875 100644 --- a/bot_anticip.c +++ b/bot_anticip.c @@ -19,8 +19,10 @@ char *bot_name() void bot_ia(char *trackname,struct _car *car,SDL_Surface *fun,int *ku,int *kd,int *kl,int *kr) { - int a1,a2,c,g,tg,og,l,x1,x2,x3,x4,y1,y2,y3,y4; + int a1,a2,l,x1,x2,x3,x4,y1,y2,y3,y4; float o,m,s; + Uint32 c; + Uint8 g,og,tg,t; /* adjust the properties depending of the track, this was "manually" optimized ;) */ if (strcmp(trackname,"car")==0) @@ -77,6 +79,15 @@ void bot_ia(char *trackname,struct _car *car,SDL_Surface *fun,int *ku,int *kd,in s=car->speed/3.3+0.4; og=1; } + else if (strcmp(trackname,"formula")==0) + { + a1=150; + a2=90; + o=0.8; + m=0.1; + s=car->speed/3.3+0.4; + og=120; + } /* some default values that may work on some tracks */ else { @@ -95,8 +106,8 @@ void bot_ia(char *trackname,struct _car *car,SDL_Surface *fun,int *ku,int *kd,in { x1=car->x-cos(car->angle)*l*s; y1=car->y-sin(car->angle)*l*s; - if (x1>0 && y1>0 && x1w && y1h) c=getpixel(fun,x1,y1); else c=0; - g=(c>>GSHIFT)&0xff; + if (x1>0 && y1>0 && x1w && y1h) c=getpixel(fun,x1,y1); else c=SDL_MapRGB(fun->format,0,0,0); + SDL_GetRGB(c,fun->format,&t,&g,&t); if (gspeed>m) { *ku=0,*kd=1; break; } } @@ -112,10 +123,10 @@ void bot_ia(char *trackname,struct _car *car,SDL_Surface *fun,int *ku,int *kd,in x4=car->x-cos(car->angle+o)*l*s; y4=car->y-sin(car->angle+o)*l*s; - if (x3>0 && y3>0 && x3w && y3h) c=getpixel(fun,x3,y3); else c=0; - tg=(c>>GSHIFT)&0xff; - if (x4>0 && y4>0 && x4w && y4h) c=getpixel(fun,x4,y4); else c=0; - g=(c>>GSHIFT)&0xff; + if (x3>0 && y3>0 && x3w && y3h) c=getpixel(fun,x3,y3); else c=SDL_MapRGB(fun->format,0,0,0); + SDL_GetRGB(c,fun->format,&t,&tg,&t); + if (x4>0 && y4>0 && x4w && y4h) c=getpixel(fun,x4,y4); else c=SDL_MapRGB(fun->format,0,0,0); + SDL_GetRGB(c,fun->format,&t,&g,&t); if (g>tg) { *kr=1; break; } else if (g