2002/colera.r
001 | /* *************************** COLERA ******************* */ |
002 |
003 |
004 | /* crobot di : |
005 |
006 | QUESTO HA 890 ISTRUZIONI MA GAREGGIA NELLA CLASSE 2000 |
007 |
008 | LUCA STRINGHER |
009 |
010 | COME SI COMPORTA: |
011 |
012 | Colera va all'angolo pi� vicino e vibra in diagonale, ogni dieci vibrazioni controlla quanta gente c'�. Quando rimangono in due si comporta in modo differente in base ai danni subiti. |
013 | se ne ha pochi corre dietro al'avversario e gli spara, se � oltre il 30 % di danni si sposta al centro e viaggia all'interno di un quadrato tramite la funzione rand() (molto carina) |
014 |
015 | */ |
016 |
017 |
018 |
019 |
020 |
021 | int dir,xi,yi,i,ang,angm,d,d0,d1,d2,a,b,v,dq,angq,q,c,q1,q2,r,x,y,k,e; |
022 |
023 | main() |
024 | {c=0;r=20;k=0; |
025 | inoculazione(); |
026 | avvicinamento(); |
027 | |
028 | while (1) |
029 | { |
030 | tremore(); |
031 | c+=1;r-=5; if (r<5) r=20; |
032 | if (c>10) |
033 | { |
034 | c=0; |
035 | linfociti(5);q1=q; |
036 | linfociti(3);q2=q; |
037 | } |
038 | if (q1==1 && q2==1){k=1;febbre();} |
039 |
040 | } |
041 | } |
042 |
043 | inoculazione() |
044 | { |
045 | if (loc_x()>500){i=2;} else {i=1;} |
046 | if (loc_y()>500){i+=1; if (i==2){i=4;}} |
047 | trasmissione(i); |
048 | } |
049 |
050 | trasmissione(I) |
051 | { |
052 | if (I==1){xi=70 ;yi=70;angm=90;e=45;} |
053 | if (I==4){xi=70; yi=930;angm=360;e=315;} |
054 | if (I==2){xi=930;yi=70;angm=180;e=315;} |
055 | if (I==3){xi=930;yi=930;angm=270;e=45;} |
056 | ang=angm-90; |
057 | } |
058 |
059 | distanza(X,Y) |
060 | { |
061 | return ( sqrt ((loc_x()-X)*(loc_x()-X)+(loc_y()-Y)*(loc_y()-Y))); |
062 | } |
063 |
064 | direzione(X,Y) |
065 | { |
066 | if (X>loc_x()){dir= atan (100000*(loc_y()-Y)/(loc_x()-X));} |
067 | else {dir= atan (100000*(loc_y()-Y)/(loc_x()-X))+180;} |
068 | return (dir); |
069 | } |
070 |
071 | epidemia(K) |
072 | { |
073 | d0=scan(ang,10); |
074 | if (d0>0 && d0<750) |
075 | { |
076 | if (!(d1=scan(ang+=5,5))) ang-=10; |
077 | if (!(d2=scan(ang+=3,3))) ang-=6; |
078 | d2=scan(ang,3); |
079 | d=2*d2-d0; |
080 | /*if(d>20) |
081 | {*/ cannon(ang,d); /*}*/ |
082 | } |
083 | else { if (scan(ang+=20,10)); |
084 | else if (scan(ang-=40)); |
085 | else ang+=80; } |
086 | if (K==0 && ang>angm){ang=angm-90;} |
087 | } |
088 |
089 |
090 | avvicinameto() |
091 | { |
092 | a=100;v=100; |
093 | while (a>10) |
094 | { |
095 | while (distanza(xi,yi)>a) |
096 | {drive(direzione(xi,yi),v);epidemia(k);} |
097 | a-=30;v-=30; |
098 | } |
099 | drive(direzione(xi,yi),0); |
100 | } |
101 |
102 | incubazione(X,Y) |
103 | { |
104 | x= rand (r)+X;b=0; |
105 | while (speed()>49) |
106 | {epidemia(k);} |
107 | while (loc_x()<x){drive(b,100);epidemia(k);} |
108 | drive(b,0); |
109 | y= rand (r)+Y;b=90; |
110 | while (speed()>49); |
111 | {epidemia(k);} |
112 | while (loc_y()<y){drive(b,100);epidemia(k);} |
113 | drive(b,0); |
114 | x= rand (r)+X;b=180; |
115 | while (speed()>49); |
116 | {epidemia(k);} |
117 | while (loc_x()>x){drive(b,100);epidemia(k);} |
118 | drive(b,0); |
119 | y= rand (r)+Y;b=270; |
120 | while (speed()>49); |
121 | {epidemia(k);} |
122 | while (loc_y()>y){drive(b,100);epidemia(k);} |
123 | drive(b,0); |
124 | } |
125 |
126 | linfociti(F) |
127 | { |
128 | q=0; |
129 | angq=angm-90-F; |
130 | while (angq<angm+10) |
131 | { |
132 | dq=scan(angq,10); |
133 | angq+=20; |
134 | if (dq>0){q+=1;} |
135 | } |
136 | } |
137 |
138 | febbre() |
139 | { |
140 | if (damage()<35) |
141 | { |
142 | while (1) |
143 | { |
144 | if (scan(ang,10)) {drive(ang,100);cannon(ang,scan(ang,10));} |
145 | else ang+=20; |
146 | } |
147 | } |
148 | else |
149 | { |
150 | while (1) |
151 | {r=100; |
152 | incubazione(450,450); |
153 | } |
154 | } |
155 | } |
156 |
157 | tremore() |
158 | { |
159 | while (loc_x()<(xi+ rand (10))) |
160 | {drive(e,100);epidemia(k);} |
161 | drive(e,0); while (speed()>49) epidemia(k); |
162 | while (loc_x()>(xi- rand (10))) |
163 | {drive(e+180,100);epidemia(k);} |
164 | drive(e+180,0); while (speed()>49) epidemia(k); |
165 | } |
166 |
167 |
168 | /* CHE VINCA IL MIGLIORE, XKE' L'IMPORTANTE NON E' PARTECIPARE MA VINCERE */ |