1998/rudolf_3.r
001 | /* R U D O L F III |
002 | the revenge |
003 |
004 | AUTORE |
005 | Nome: Carlin Bruno |
006 |
007 | SCHEDA TECNICA: |
008 | Inizialmente il crobot raggiunge l' angolo piu' vicino, dove inizia ad |
009 | oscillare inclinato di 25 gradi rispetto all' orizzontale. Se pensa |
010 | di subire troppo raggiunge un angolo adiacente, sempreche' sia libero (se |
011 | li trova entrambi occupati non si sposta) e li riprende lo stesso movimento. |
012 | Quando vede un solo nemico nell' arena lo attacca con una strategia identica a |
013 | quella usata dai crobot VISION.R e ________.R (The Invisible Man) iscritti |
014 | a questo stesso torneo da Alessandro (Carlin). Se si eccettua quest' ultima |
015 | parte il Rudolf_3 e' sostanzialmente molto simile ai suoi predecessori |
016 | Rudolf e Rudolf_2. In particolare e' stata migliorata la procedura di fuoco |
017 | che effettua una scansione di una zona piu' ampia attorno alla posizione in |
018 | cui era stato trovato in precedenza un nemico. */ |
019 |
020 | int odam,x,y,trov,deg,r,rng,dir,dam,t,l,ang,d,a1,a2,aw1,aw2,temp,l,t,p,dd,m; |
021 |
022 | /* principale */ |
023 |
024 | main() { |
025 | t=50; |
026 | m=30; |
027 | risp=0; |
028 | if (loc_x()<500) {l=100; |
029 | { if (loc_y()<500) {vai(170,110);a1=4;} |
030 | else {vai(170,999);a1=3;} } } |
031 | else {l=900;{ if (loc_y()<500) {vai(950,100);a1=1;} |
032 | else {vai(970,999);a1=2; }} } |
033 | aw1=(a1*90)%360; |
034 | aw2=aw1+90; |
035 | deg=aw1; |
036 | while (1){ |
037 | while (t){ |
038 | odam=damage(); |
039 | while ((t)&&(damage()<odam+m)) veloce(l); |
040 | rad=radar(); |
041 | if ((rad<2)) end(); |
042 | if ((t<1) && (damage()>80)) { while (1) veloce(l);} |
043 | else |
044 | { if (t>1) { |
045 | cerca(); |
046 | if (risp=1) { |
047 | fuggi(); |
048 | risp=0; |
049 | m=20; |
050 | aw1=(a1*90)%360; |
051 | aw2=aw1+90; |
052 | } } |
053 | } |
054 | } |
055 | t=20; |
056 | } |
057 | } |
058 |
059 | /* attacco finale */ |
060 |
061 | end() |
062 | { |
063 | vai(loc_x()+(500-loc_x())/15,500); |
064 | while (1) |
065 | { |
066 | drive(0,100); while (loc_x() < 900) if (pp=scan(deg,10)) |
067 | cannon(deg+=7*(!(scan(deg+356,7)))+353*(!(scan(deg+4,7))),2*scan(deg,10)-pp); |
068 | else deg+=21; |
069 | drive(0,0); destroy(); |
070 | drive(180,100); while (loc_x() > 100) if (pp=scan(deg,10)) |
071 | cannon(deg+=7*(!(scan(deg+356,7)))+353*(!(scan(deg+4,7))),2*scan(deg,10)-pp); |
072 | else deg+=21; |
073 | drive(180,0); destroy(); |
074 | } |
075 |
076 | } |
077 |
078 | /* movimento oscillatorio */ |
079 |
080 | veloce(ubi){ |
081 | drive(205,100); |
082 | while (loc_x()>=ubi) {fuoco();drive(205,100);} |
083 | drive(25,100); |
084 | fuoco(); |
085 | drive(25,100); |
086 | while (loc_x()<ubi) {fuoco();drive(25,100);} |
087 | drive(205,100); |
088 | fuoco(); |
089 | --t; |
090 | } |
091 |
092 | /* sparo durante l' oscillazione */ |
093 |
094 | fuoco() |
095 | { |
096 | if (!(rng=scan(deg,10))) |
097 | if (!(rng=scan(deg-=20,10))) |
098 | if (!(rng=scan(deg+=40,10))) |
099 | if (!(rng=scan(deg-=60,10))) |
100 | if (!(rng=scan(deg+=80,10))) { deg+=60; return ; } |
101 | if (!scan(deg+=5,5)) deg-=10; |
102 | if (!scan(deg+=3,3)) deg-=6; |
103 | if (r=scan(deg,5)) cannon(deg,r+r-rng); |
104 | if (r>705) deg+=90; |
105 | } |
106 |
107 | /* cerco un angolo libero */ |
108 |
109 | cerca(){ |
110 | if (!r=scan(aw1,10)) {dir=aw1;a1=(a1+1)%4;risp=1;} else |
111 | if (!rn=scan(aw2,10)) {dir=aw2;a1=(a1-1)%4;risp=1;} |
112 | } |
113 |
114 | /* e lo raggiungo */ |
115 |
116 | fuggi() |
117 | { |
118 | drive (dir,100); |
119 | if (dir==0) while (loc_x()<810) fuoco(); else |
120 | if (dir==180) while (loc_x()>190) fuoco(); else |
121 | if (dir==90) while (loc_y()<950) fuoco(); else |
122 | if (dir==270) while (loc_y()>130) fuoco(); |
123 | drive(dir,0); |
124 | if (loc_x()>500) l=900; |
125 | else l=100; |
126 |
127 | } |
128 |
129 | vai(tx,ty) |
130 | { |
131 | x=loc_x()-tx; |
132 | y=(loc_y()-ty)*100000; |
133 | if (tx>loc_x()) dir=360+ atan (y/x); else dir=180+ atan (y/x); |
134 | while ((x=tx-loc_x())*x+(y=ty-loc_y())*y>8100) { drive(dir,100); fuoco(); } |
135 | drive(dir,49); |
136 | while ((x=tx-loc_x())*x+(y=ty-loc_y())*y>225); |
137 | drive(0,0); |
138 | while (speed()>49); |
139 | } |
140 |
141 | /* controllo dei nemici rimasti */ |
142 |
143 | radar() |
144 | { |
145 | int n, |
146 | da; |
147 | n=0; da=1; |
148 | while (da!=361) |
149 | { |
150 | if (scan(da,10)) ++n; |
151 | da+=18; |
152 | } |
153 | return n; |
154 | } |
155 |
156 | /* sparo veloce */ |
157 |
158 | destroy() |
159 | { |
160 | while (speed() > 49) if ((d=scan(deg,10))) { |
161 | if (!scan(deg+=5,5)) deg-=10; |
162 | cannon(deg,d); |
163 | } |
164 | else deg+=20; |
165 | } |
166 |
167 | /* ... perche' un Rudolf sia sempre in famiglia ... */ |