crobs/dirtyh.r

01int dam;
02int current;
03 
04main()
05{
06 
07        dam=0;
08  while(1)
09  {
10        current=damage();
11        if (current>dam) {
12                move();
13            
14                dam = current; }
15        else
16                rapid();
17  }
18}
19 
20move()
21{       int think;
22        int x;
23        int y;
24 
25        x = loc_x();
26        y = loc_y();
27         
28        think = 0;
29        if (( x<500 ) && (y < 500)) {
30                drive(rand(90),100);
31                while(think<50)
32                        think++;   }
33        else if (( x < 500 ) && (y>499)) {
34                drive((rand(90)+270),100);
35                while(think<50)
36                        think++; }
37        else if ((x>499) && (y<500)) {
38                drive((rand(90)+90),100);
39                while(think<50)
40                        think++; }
41        else if ((x>499) && (y>499)) {
42                drive((rand(90)+180),100);
43                while(think<50)
44                        think++; }
45drive(0,0);
46}
47 
48rapid()
49{
50     int   range;
51     int   bordum;
52     int   dam2;
53     int   heading;
54     int   current2;
55 
56        range=0;
57        bordum=0;
58        dam2=damage();
59        while(1){
60           if (bordum>10){
61                bordum=0;
62                move();
63     
64           }
65           if (range<40)
66                heading=rand(360);
67           else  {
68                bordum++;
69                cannon(heading,range); }
70           while((range=(scan(heading,5)))&&(range==0))
71           {
72           heading=heading+5;
73           if (heading>360)
74                heading=heading-360;
75           current2=damage();
76           if (dam2!=current2)  {
77                move();
78 
79                return; }
80           bordum++;
81        }
82        current2=damage();
83        if (dam2!=current2){
84                move();
85                return;    }
86}
87}