2002/copter_2.r
01 | /* |
02 | Nome: Copter_2.r |
03 | Autore: Franco Cartieri |
04 |
05 | Torneo 2002 |
06 |
07 | Copter_2.r e' un microcrobots molto semplice. Non ha routine di controllo del numero degli avversari, controllo danni subiti o routine di attacco finale. |
08 | Esegue continuamente un ciclo in cui il robot si muove in senso antiorario lungo il quadrato che si ottiene, unendo i punti centrali dei lati del campo di gioco. |
09 | La routine di sparo deriva da MicroDNA. |
10 | Spero che questo microcrobots si comporti bene nel f2f. |
11 | */ |
12 |
13 | int angdir,deg,odeg,rng,orng; |
14 |
15 | main() |
16 | { |
17 | while (1) |
18 | { |
19 | angdir=angolo(900,500); |
20 | while (loc_x()<875) fuoco(); |
21 | angdir=angolo(500,900); |
22 | while (loc_y()<875) fuoco(); |
23 | angdir=angolo(100,500); |
24 | while (loc_x()>125) fuoco(); |
25 | angdir=angolo(500,100); |
26 | while (loc_y()>125) fuoco(); |
27 | } |
28 | } |
29 |
30 | fuoco() |
31 | { |
32 | drive(angdir,100); |
33 | if (orng=scan(deg,10)) |
34 | { |
35 | if (orng<400) |
36 | { |
37 | if (orng<100) return cannon(deg,orng); |
38 | if (scan(deg-10,6)) deg-=10; |
39 | else if (scan(deg+10,6)) deg+=10; |
40 | cannon(deg,(scan(deg,10)<<1)-orng); |
41 | return ; |
42 | } |
43 | if (!scan(deg-=6,6)) deg+=12; |
44 | find(); |
45 | if (orng=scan(odeg=deg,5)) |
46 | { |
47 | find(); |
48 | cannon(deg+(deg-odeg)*((1200+(rng=scan(deg,10)))>>9)-( sin (deg-angdir)>>14), |
49 | rng*250/(250+orng-rng-( cos (deg-angdir)>>12))); |
50 | } |
51 | } |
52 | else |
53 | { |
54 | if (scan(deg-=20,10)) return fuoco(); |
55 | if (scan(deg+=40,10)) return fuoco(); |
56 | deg+=40; |
57 | } |
58 | } |
59 |
60 | find() |
61 | { |
62 | if (scan(deg-7,3)) deg-=7; |
63 | if (scan(deg+7,3)) deg+=7; |
64 | if (scan(deg-4,2)) deg-=4; |
65 | if (scan(deg+4,2)) deg+=4; |
66 | if (scan(deg-2,1)) deg-=2; |
67 | if (scan(deg+2,1)) deg+=2; |
68 | } |
69 | |
70 | angolo(xx, yy) |
71 | int xx,yy; |
72 | { |
73 | int x; |
74 | return (180+((x=xx-(loc_x()))>0)*180+ atan (((yy-loc_y())*100000)/x)); |
75 | } |