1997/carlo97.r
001 | /* |
002 | ======== VII Torneo Crobots MCmicrocomputer 1997 ========= |
003 | |
004 | Robot : CARLO97.R |
005 | |
006 | Autore: |
007 |
008 | Luigi Cimini |
009 | |
010 | SCHEDA TECNICA: |
011 |
012 | Questo robot si muove velocemente lungo i lati di un piccolo quadrato |
013 | sito nell`angolo S-E del campo di battaglia. La strategia difensiva si |
014 | basa sul movimento e sul continuo cambiamento di direzione. |
015 |
016 | L`attacco, che viene attivato solo nella fase finale del combattimento, |
017 | e` basato su rapide oscillazioni casuali verticali e su una routine di |
018 | fuoco, solo leggermente differente da quella usata nella prima fase. |
019 | |
020 | SCELTA: |
021 |
022 | Nel caso si rendesse necessario limitare i combattimenti ad un solo |
023 | robot preferisco veder combattere ANDREA97.R |
024 |
025 | */ |
026 | |
027 | int a,dd,dir,f,o,r,t,x,y,y1,y2; |
028 |
029 | main() |
030 | { |
031 | a=100; r=60; o=60; t=240; /* ~450000 cicli */ |
032 |
033 | while (loc_x()>910) {drive(180,49); cerca();} |
034 | while (loc_x()<930) {drive(0, 100); cerca();} /* ---> */ |
035 | while (speed() >49) {drive(180, 0); cerca();} |
036 | while (loc_y() <70) {drive(90, 49); cerca();} /* */ |
037 |
038 | while (--t) /* quadrilatero */ |
039 | { |
040 | drive(270,100); while (loc_y() > 90) cerca(); /* */ |
041 | drive(90,0); while (speed() > 49) cerca(); |
042 | drive(180,100); while (loc_x() >815) cerca(); /* �--- */ |
043 | drive(0,0); while (speed() > 49) cerca(); |
044 | drive(90,100); while (loc_y() <185) cerca(); /* */ |
045 | drive(270,0); while (speed() > 49) cerca(); |
046 | drive(0,100); while (loc_x() <910) cerca(); /* ---> */ |
047 | drive(180,0); while (speed() > 49) cerca(); |
048 | } |
049 | dir=135; f=0; /* attacco */ |
050 | while (1) |
051 | { |
052 | while (speed()<67) {drive(dir,100); cerca1();} |
053 | dd=dir+180; |
054 | while (speed()> 0) {drive(dd, 0); cerca1();} |
055 | if (f=!f) dir=a+375; else dir=a+135; |
056 | x=loc_x(); y=loc_y(); /* evita muro */ |
057 | if ((x<167)||(x>833)||(y<167)||(y>833)) |
058 | { |
059 | while (loc_x()<400) {drive(0, 100); cerca();} |
060 | while (loc_x()>600) {drive(180,100); cerca();} |
061 | while (speed()> 49) {drive(0, 0); cerca();} |
062 | while (loc_y()<400) {drive(90, 100); cerca();} |
063 | while (loc_y()>600) {drive(270,100); cerca();} |
064 | while (speed()> 49) {drive(90, 0); cerca();} |
065 | } |
066 | y2=loc_y()+50; y1=y2-100; /* osc. rnd vert. */ |
067 | while (loc_y()<y2) {drive(90, 100); cerca1();} |
068 | while (speed()>49) {drive(270, 0); cerca1();} |
069 | while (loc_y()>y1) {drive(270,100); cerca1();} |
070 | while (speed()>49) {drive(90, 0); cerca1();} |
071 | } |
072 | } |
073 | spara() |
074 | { |
075 | if (scan(a+6,6)) a+=6; else a-=6; |
076 | if (scan(a+3,3)) a+=3; else a-=3; |
077 | r=scan(a,10); cannon(a,r+(r-o)*2); |
078 | } |
079 | cerca() |
080 | { |
081 | if (o=scan(a,10)) spara(); |
082 | else if (o=scan(a-=20,10)) spara(); |
083 | else if (o=scan(a+=40,10)) spara(); |
084 | else a+=30; |
085 | if (o>766) a+=30; |
086 | } |
087 | spara1() |
088 | { |
089 | if (scan(a+6,6)) a+=6; else a-=6; |
090 | if (scan(a+3,3)) a+=3; else a-=3; |
091 | r=scan(a,10); cannon(a,r+r-o); |
092 | } |
093 | cerca1() |
094 | { |
095 | if (o=scan(a,10)) spara(); |
096 | else if (o=scan(a-=20,10)) spara1(); |
097 | else if (o=scan(a+=40,10)) spara1(); |
098 | else a+=30; |
099 | if (o>766) a+=30; |
100 | } |