1994/shadow.r
001 | /*{ Author : Marco Varagnolo } |
002 | { Robot : Shadow } |
003 |
004 | � STRATEGY � |
005 |
006 | { Il robot si muove sul campo di battaglia eseguendo dei giri in } |
007 | { senso orario, e a seconda del senso di marcia (right,down,left, } |
008 | { up) vengono attivate delle procedure (radar1,radar2,radar3 } |
009 | { radar4) che controllano dove sparare. } |
010 | { Quando pero' la percentuale dei danni supera il 50% (la percen- } |
011 | { tuale effettiva � per� nella maggior parte dei casi sempre mol- } |
012 | { to superiore al 50%) allora il robot cambia strategia e si ri- } |
013 | { fugia sul lato sinistro dell'area di combattimento, e muovendo- } |
014 | { si lungo questo lato spara variando il range a seconda della } |
015 | { distanza del bersaglio. } |
016 |
017 |
018 | � NOTE � |
019 |
020 | { Shadow non � altro che una versione migliorata del robot che ha } |
021 | { partecipato al precedente torneo (Mutation). In particolare � } |
022 | { stato ritoccato il range per il fuoco permettendomi ora di in- } |
023 | { fligge pi� danni, ed � stato ritoccato il moviemnto per il campo } |
024 | { di battaglia che causava danni sbattendo sui muri.... L'idea non } |
025 | { mi sembra male cosi' ho deciso di continuare su questa strada, } |
026 | { penso che al prossimo torneo (...beh, bisogna sempre pianifica- } |
027 | { re tutto) mandero' un robot che si trasforma durante la batta- } |
028 | { glia........eh...bella vaccat..mah.....si vedra'. }*/ |
029 |
030 |
031 |
032 | int d,ang,newrange,oldrange; |
033 | main() |
034 | { |
035 |
036 | while ( d <= 50 ) /*Esegue la prima tattica finch� i danni sono < del 50%*/ |
037 | { |
038 | if (loc_x()>=80) left(); |
039 | else |
040 | right(); |
041 | if (loc_y()>=920) down(); |
042 | else |
043 | up(); |
044 | } |
045 |
046 | if ( d > 50 ) /*Quando i danni superano il 50% adotta la seconda tattica*/ |
047 | { |
048 | left(); |
049 | while (damage()!=100) defence(); |
050 | } |
051 | } |
052 |
053 |
054 |
055 | left() |
056 | { |
057 | while (loc_x()>=100) |
058 | { |
059 | d=damage(); |
060 | drive(180,100); |
061 | radar1(); |
062 | } |
063 | } |
064 |
065 | down() |
066 | { |
067 | while (loc_y()>=100) |
068 | { |
069 | d=damage(); |
070 | drive(270,100); |
071 | radar2(); |
072 | } |
073 | } |
074 |
075 | right() |
076 | { |
077 | while (loc_x()<=900) |
078 | { |
079 | d=damage(); |
080 | drive(0,100); |
081 | radar3(); |
082 | } |
083 | } |
084 |
085 | up() |
086 | { |
087 | while (loc_y()<=900) |
088 | { |
089 | d=damage(); |
090 | drive(90,100); |
091 | radar4(); |
092 | } |
093 | } |
094 |
095 | defence() /* Tattica adottata in caso di danni superiori al 50% */ |
096 | { |
097 | ang=270; |
098 | drive(90,0); |
099 | while (speed()>50) newfire(); |
100 | while (damage()!=100) |
101 | { |
102 | drive(90,100); |
103 | while (loc_y()<920) newfire(); |
104 | drive(270,0); |
105 | while (speed()>50) newfire(); |
106 | drive(270,100); |
107 | while (loc_y()>80) newfire(); |
108 | drive(90,0); |
109 | while (speed()>50) newfire(); |
110 | } |
111 | } |
112 |
113 | newfire() /* Procedura per variare il range a seconda del bersaglio */ |
114 | { |
115 |
116 | if (newrange=scan(ang,10)) |
117 | { |
118 | if (oldrange<newrange) |
119 | { |
120 | cannon(ang,8*newrange/7); |
121 | oldrange=newrange; |
122 | } |
123 | else |
124 | { |
125 | cannon(ang,7*newrange/8); |
126 | oldrange=newrange; |
127 | } |
128 | } |
129 | else |
130 | { |
131 | ang+=14; |
132 | if (ang>359) |
133 | ang-=354; |
134 | else |
135 | if (ang>90) |
136 | ang+=186; |
137 |
138 | } |
139 | } |
140 |
141 |
142 | radar1() /* Procedura di fuoco per la prima tattica */ |
143 | { |
144 | if (range=scan(180,10)) cannon(180,range); |
145 | if (range=scan(135,10)) cannon(135,range); |
146 | if (range=scan(45,10)) cannon(45,range); |
147 | if (range=scan(0,10)) cannon(0,range); |
148 | } |
149 |
150 | radar2() /* Procedura di fuoco per la prima tattica */ |
151 | { |
152 | if (range=scan(270,10)) cannon(270,range); |
153 | if (range=scan(225,10)) cannon(225,range); |
154 | if (range=scan(90,10)) cannon(90,range); |
155 | if (range=scan(135,10)) cannon(135,range); |
156 | } |
157 |
158 | radar3() /* Procedura di fuoco per la prima tattica */ |
159 | { |
160 | if (range=scan(0,10)) cannon(0,range); |
161 | if (range=scan(315,10)) cannon(315,range); |
162 | if (range=scan(180,10)) cannon(180,range); |
163 | if (range=scan(225,10)) cannon(225,range); |
164 | } |
165 |
166 | radar4() /* Procedura di fuoco per la prima tattica */ |
167 | { |
168 | if (range=scan(90,10)) cannon(90,range); |
169 | if (range=scan(45,10)) cannon(45,range); |
170 | if (range=scan(270,10)) cannon(270,range); |
171 | if (range=scan(315,10)) cannon(315,range); |
172 | } |