crobs/stush-1.r
01 | /* C-bots Tournament 2nd place: Stush-1.r */ |
02 |
03 |
04 | /* |
05 | Move around like a bouncing ball at max. speed possible. |
06 | Scan for targets. When a target is found, continually fire at |
07 | it. It if dissapears, scan to the left and right of last know location. |
08 | */ |
09 |
10 | main() |
11 | { |
12 | int d,old; |
13 | int x; |
14 | int y; |
15 | int flag; |
16 |
17 | d=45; |
18 | old=45; |
19 | flag=1; |
20 |
21 | while (1) { |
22 |
23 | if (d!=old) { |
24 | drive(d,49); |
25 | old=d; |
26 | } |
27 | else drive(d,100); |
28 |
29 | x=loc_x(); y=loc_y(); |
30 |
31 | if (x<100 && d==135) d=45; |
32 | if (x<100 && d!=45) d=315; |
33 |
34 | if (x>900 && d==45) d=135; |
35 | if (x>900 && d!=135) d=225; |
36 |
37 | if (y<100 && d==315) d=45; |
38 | if (y<100 && d!=45) d=135; |
39 |
40 | if (y>900 && d==45) d=315; |
41 | if (y>900 && d!=315) d=225; |
42 |
43 | if (flag) { |
44 | if (s=scan(f,10)) cannon(f,s); |
45 | else if (s=scan(f+20,10)) f+=20; |
46 | else if (s=scan(f-20,10)) f-=20; |
47 | else flag = 0; |
48 | if (s=scan(f,10)) cannon(f,s); |
49 | } |
50 | else { |
51 | f+=85; |
52 | if (s=scan(f,10)) { |
53 | cannon(f,s); |
54 | flag=1; |
55 | } |
56 | } |
57 |
58 | } |
59 |
60 | } |