2015/one.r
001 | /******************* |
002 | * * |
003 | * O N E .r * |
004 | * * |
005 | ******************* |
006 |
007 | Michelangelo Messina |
008 |
009 |
010 | Robot senza nessuna pretesa, se non di tentare di far bene nel KingOfTheHill. |
011 | E' composto solo di routine f2f |
012 |
013 |
014 | */ |
015 |
016 |
017 | int deg,odeg, /*angolo di sparo*/ |
018 | rng, /*distanza*/ |
019 | dir; /*direzione*/ |
020 | int orng; |
021 | int x,y,b,dam; |
022 |
023 |
024 | fuoco() |
025 | { |
026 | if (scan(deg,10)); |
027 | else if (scan(deg+=20,10)); |
028 | else if (scan(deg-=40,10)); |
029 | else if (scan(deg+=60,10)); |
030 | else if (scan(deg-=80,10)); |
031 | else { |
032 | if (orng=scan(deg+=100,10)) return cannon(deg,orng); |
033 | else if (orng=scan(deg-=120,10)) return cannon(deg,orng); |
034 | else if (orng=scan(deg+=140,10)) return cannon(deg,orng); |
035 | else if (orng=scan(deg-=160,10)) return cannon(deg,orng); |
036 | else if ((orng=scan(deg-=20,10))) return cannon(deg,orng); |
037 | else if ((orng=scan(deg+=200,10))) return cannon(deg,orng); |
038 | else return deg+=100; |
039 | } |
040 |
041 | if (scan(deg-18,10)) deg-=7; else deg+=1; |
042 | if (scan(deg+18,10)) deg+=7; else deg-=1; |
043 |
044 | |
045 | if (orng=refine()) { |
046 | if (rng=refine(odeg=deg)) |
047 | cannon(deg+(deg-odeg)*((1200+rng)>>9)-( sin (deg-dir)>>14), |
048 | rng*192/(192+orng-rng-( cos (deg-dir)>>12))); |
049 | } |
050 | } |
051 |
052 | refine() { |
053 | if (scan(deg+13,10)) deg+=5; if (scan(deg-13,10)) deg-=5; |
054 | if (scan(deg+12,10)) deg+=3; if (scan(deg-12,10)) deg-=3; |
055 | if (scan(deg+10,10)) deg+=1; if (scan(deg-10,10)) deg-=1; |
056 | return scan(deg,10); |
057 |
058 | } |
059 |
060 | spara() |
061 | { |
062 | drive(dir,100); |
063 | if ((orng=scan(deg, 10)) ) { |
064 | if (scan(deg-15,10)) { |
065 | if (scan(deg-=13,4)) { |
066 | if (scan(deg-3,5)) deg-=5; |
067 | else ++deg; |
068 | } else if (scan(deg-5,5)) deg-=5; |
069 | } else if (scan(deg+14,10)) { |
070 | if (scan(deg+=13,5)) deg+=5; |
071 | else --deg; |
072 | } else if (scan(deg+4,5)) deg+=5; |
073 | else deg-=5; |
074 |
075 | } else if ((orng=scan(deg-=20,10))) { |
076 | if (scan(deg-9,10)) { |
077 | if (scan(deg-=13,5)) deg-=5; |
078 | else ++deg; |
079 | } else if (scan(deg+9,10)) deg+=6; |
080 | } else if ((orng=scan(deg+=40,10))) { |
081 | if (scan(deg+9,10)) deg+=12; |
082 | } else if ((orng=scan(deg+=20,10))); |
083 | else { |
084 | if ((orng=scan(deg-=80,10))) cannon(deg,orng); |
085 | else if ((orng=scan(deg-=20,10))) cannon(deg,orng); |
086 | else if ((orng=scan(deg+=120,10))) cannon(deg,orng); |
087 | else if ((orng=scan(deg+=20,10))) cannon(deg,orng); |
088 | else if ((orng=scan(deg-=160,10))) cannon(deg,orng); |
089 | else if ((orng=scan(deg-=20,10))) cannon(deg,orng); |
090 | else if ((orng=scan(deg+=200,10))) cannon(deg,orng); |
091 | else deg+=80; |
092 | return ; |
093 | } |
094 | if (rng=scan(deg,10)){ |
095 | cannon (deg, rng*145/(145+orng-rng) ); |
096 | } else if (rng=scan(deg-=20,10)) cannon(deg,rng); |
097 | else if (rng=scan(deg+=40,10)) cannon(deg,rng); |
098 | else deg+=40; |
099 | } |
100 |
101 | main() |
102 | { |
103 | if (loc_y(x=(loc_x()>500))>500) { |
104 | if (x) spara(dir=deg=195); |
105 | else spara(dir=deg=285); |
106 | } else { |
107 | if (x) spara(dir=deg=105); |
108 | else spara(dir=deg=375); |
109 | } |
110 | fuoco(drive(dir,100)); |
111 | while (1) { |
112 | if (orng>640) dir=deg+25+(b^=1)*250; |
113 | else if (orng>151) dir=deg+80+(b^=1)*200; |
114 | else dir=(deg/90)*90; |
115 | if ((x=loc_x(y=loc_y()))>835) dir=165+30*(y>500); |
116 | else if (x<165) dir=345+30*(y<500); |
117 | else if (y>835) dir=255+30*(x<500); |
118 | else if (y<165) dir=75+30*(x>500); |
119 | else if (dam>80) dir+=180; |
120 | dam=damage(spara()); |
121 | if (scan(deg-15,10)) deg-=4; |
122 | if (scan(deg+15,10)) deg+=4; |
123 | spara(); |
124 | if (orng>459) { |
125 | fuoco(drive(dir,100)); |
126 | } |
127 | |
128 | } |
129 | } |