[3945] | 1 | -- Global Variables |
---|
| 2 | allOk = true |
---|
[3951] | 3 | cellReached = false |
---|
[3945] | 4 | guidePositionReached = false |
---|
| 5 | prisonerReachedLock = false |
---|
| 6 | hangarReached = false |
---|
| 7 | |
---|
[3966] | 8 | height = 100 |
---|
[3946] | 9 | |
---|
| 10 | -- Returns the distance between (x1,x2,x3) and (y1,y2,y3) |
---|
| 11 | function dist( x1,x2,x3, y1,y2,y3 ) |
---|
| 12 | return math.sqrt( (x1-y1)^2 + (x2-y2)^2 + (x3-y3)^2 ) |
---|
| 13 | end |
---|
| 14 | |
---|
| 15 | |
---|
[3951] | 16 | function observeGuard() |
---|
| 17 | guardX = guard:getAbsCoorX() |
---|
| 18 | guardY = guard:getAbsCoorY() |
---|
| 19 | guardZ = guard:getAbsCoorZ() |
---|
| 20 | |
---|
[3965] | 21 | if dist( guardX,guardY,guardZ,35.48, 29, 191.28 ) < 30 then |
---|
[3945] | 22 | allOk = false |
---|
| 23 | end |
---|
| 24 | |
---|
[3951] | 25 | end |
---|
| 26 | |
---|
[3946] | 27 | function observePrisoner() |
---|
[3945] | 28 | |
---|
[3962] | 29 | prisonerX = prisoner:getAbsCoorX() |
---|
| 30 | prisonerY = prisoner:getAbsCoorY() |
---|
| 31 | prisonerZ = prisoner:getAbsCoorZ() |
---|
[3946] | 32 | |
---|
[3964] | 33 | if dist( prisonerX,prisonerY,prisonerZ,162.757919,49,363.489349 ) < 60 then |
---|
[3965] | 34 | --io.write("Prisonner reached lock \n") |
---|
| 35 | prisonerReachedLock = true |
---|
[3945] | 36 | end |
---|
| 37 | |
---|
[3951] | 38 | end |
---|
[3945] | 39 | |
---|
[3954] | 40 | cellProgrammed = false |
---|
[3951] | 41 | function goToCell(timestep) |
---|
| 42 | |
---|
[3954] | 43 | if not cellProgrammed then |
---|
[3964] | 44 | secondguard:walkTo( 442.173767, height, 176.429855) |
---|
| 45 | secondguard:walkTo( 442.173767, height, 176.429855) |
---|
| 46 | secondguard:walkTo( 436.727753, height, 188.191757) |
---|
| 47 | secondguard:walkTo( 432.311584, height, 198.882462) |
---|
| 48 | secondguard:walkTo( 426.079590, height, 213.968994) |
---|
| 49 | secondguard:walkTo( 420.553986, height, 226.714996) |
---|
| 50 | secondguard:walkTo( 412.681915, height, 235.053696) |
---|
| 51 | secondguard:walkTo( 398.758545, height, 241.846924) |
---|
| 52 | secondguard:walkTo( 384.690735, height, 242.851395) |
---|
| 53 | secondguard:walkTo( 348.930481, height, 242.394958) |
---|
| 54 | secondguard:walkTo( 336.467926, height, 241.985764) |
---|
| 55 | secondguard:walkTo( 324.042999, height, 241.577774) |
---|
| 56 | secondguard:walkTo( 303.851410, height, 240.914841) |
---|
| 57 | secondguard:walkTo( 293.013977, height, 240.559006) |
---|
| 58 | secondguard:walkTo( 276.207611, height, 240.007233) |
---|
| 59 | secondguard:walkTo( 261.475800, height, 239.523544) |
---|
| 60 | secondguard:walkTo( 239.185089, height, 238.791687) |
---|
| 61 | secondguard:walkTo( 226.655655, height, 238.491974) |
---|
| 62 | secondguard:walkTo( 211.996979, height, 238.851044) |
---|
| 63 | secondguard:walkTo( 192.956741, height, 239.859207) |
---|
| 64 | secondguard:walkTo( 178.496552, height, 241.852539) |
---|
| 65 | secondguard:walkTo( 160.421860, height, 244.009827) |
---|
| 66 | secondguard:walkTo( 145.371857, height, 244.946075) |
---|
| 67 | secondguard:walkTo( 129.918198, height, 245.307037) |
---|
| 68 | secondguard:walkTo( 113.065468, height, 245.108231) |
---|
| 69 | secondguard:walkTo( 99.159073, height, 244.695694) |
---|
| 70 | secondguard:walkTo( 82.069923, height, 244.188766) |
---|
| 71 | secondguard:walkTo( 65.880531, height, 243.708527) |
---|
| 72 | secondguard:walkTo( 48.133881, height, 243.182114) |
---|
| 73 | secondguard:walkTo( 34.706280, height, 242.783813) |
---|
| 74 | secondguard:walkTo( 20.682344, height, 242.367783) |
---|
| 75 | secondguard:walkTo( 5.419819, height, 241.915070) |
---|
| 76 | secondguard:walkTo( -10.556346, height, 241.058746) |
---|
| 77 | secondguard:walkTo( -24.159513, height, 240.127090) |
---|
| 78 | secondguard:walkTo( -33.819145, height, 239.995453) |
---|
| 79 | secondguard:walkTo( -45.414162, height, 240.373322) |
---|
| 80 | secondguard:walkTo( -60.228550, height, 240.856079) |
---|
| 81 | secondguard:walkTo( -73.269897, height, 241.260895) |
---|
| 82 | secondguard:walkTo( -86.128647, height, 240.457886) |
---|
| 83 | secondguard:walkTo( -100.443581, height, 236.485718) |
---|
| 84 | secondguard:walkTo( -112.346939, height, 233.967209) |
---|
| 85 | secondguard:walkTo( -127.331635, height, 227.615112) |
---|
| 86 | secondguard:walkTo( -135.153656, height, 215.476883) |
---|
| 87 | secondguard:walkTo( -131.529984, height, 202.931015) |
---|
| 88 | secondguard:walkTo( -122.671799, height, 193.644669) |
---|
| 89 | secondguard:walkTo( -113.823517, height, 183.986633) |
---|
| 90 | secondguard:walkTo( -104.089592, height, 170.659729) |
---|
[3954] | 91 | cellProgrammed = true |
---|
| 92 | end |
---|
| 93 | |
---|
| 94 | if secondguard:finalGoalReached() then |
---|
| 95 | return true |
---|
| 96 | end |
---|
| 97 | |
---|
[3945] | 98 | return false |
---|
| 99 | end |
---|
| 100 | |
---|
[3954] | 101 | guideProgrammed = false |
---|
[3945] | 102 | function goToGuidePosition(timestep) |
---|
| 103 | |
---|
[3954] | 104 | if not guideProgrammed then |
---|
[3964] | 105 | secondguard:walkTo( -104.757011, height, 171.200729) |
---|
| 106 | secondguard:walkTo( -100.266739, height, 171.345627) |
---|
| 107 | secondguard:walkTo( -91.152046, height, 171.639709) |
---|
| 108 | secondguard:walkTo( -85.456375, height, 171.823486) |
---|
| 109 | secondguard:walkTo( -74.048538, height, 172.191589) |
---|
| 110 | secondguard:walkTo( -53.574173, height, 172.852219) |
---|
| 111 | secondguard:walkTo( -43.275124, height, 173.184540) |
---|
| 112 | secondguard:walkTo( -35.155544, height, 173.446518) |
---|
| 113 | secondguard:walkTo( -31.645050, height, 173.559784) |
---|
| 114 | secondguard:walkTo( -23.426588, height, 173.824966) |
---|
| 115 | secondguard:walkTo( -10.576803, height, 174.239578) |
---|
| 116 | secondguard:walkTo( -2.389911, height, 174.503754) |
---|
| 117 | secondguard:walkTo( 6.950986, height, 174.805176) |
---|
| 118 | secondguard:walkTo( 16.313608, height, 175.161179) |
---|
| 119 | secondguard:walkTo( 23.271458, height, 175.547226) |
---|
| 120 | secondguard:walkTo( 31.248058, height, 176.199890) |
---|
| 121 | secondguard:walkTo( 43.694778, height, 177.753479) |
---|
| 122 | secondguard:walkTo( 50.441612, height, 178.595612) |
---|
| 123 | secondguard:walkTo( 71.374535, height, 181.208389) |
---|
| 124 | secondguard:walkTo( 82.251022, height, 181.855988) |
---|
| 125 | secondguard:walkTo( 91.975792, height, 182.434998) |
---|
| 126 | secondguard:walkTo( 101.695015, height, 183.013672) |
---|
| 127 | secondguard:walkTo( 110.377205, height, 183.530609) |
---|
| 128 | secondguard:walkTo( 122.299400, height, 184.240448) |
---|
| 129 | secondguard:walkTo( 129.848495, height, 184.689911) |
---|
| 130 | secondguard:walkTo( 141.687805, height, 185.394821) |
---|
| 131 | secondguard:walkTo( 150.166702, height, 186.776016) |
---|
| 132 | secondguard:walkTo( 155.342255, height, 189.285080) |
---|
| 133 | secondguard:walkTo( 162.508133, height, 192.849976) |
---|
| 134 | secondguard:walkTo( 171.747696, height, 197.075134) |
---|
| 135 | secondguard:walkTo( 177.846390, height, 199.864029) |
---|
| 136 | secondguard:walkTo( 182.707596, height, 204.381516) |
---|
| 137 | secondguard:walkTo( 182.707596, height, 204.381516) |
---|
| 138 | secondguard:walkTo( 187.317139, height, 211.966385) |
---|
| 139 | secondguard:walkTo( 193.191528, height, 221.632446) |
---|
| 140 | secondguard:walkTo( 197.856018, height, 229.307724) |
---|
| 141 | secondguard:walkTo( 198.350906, height, 232.634857) |
---|
| 142 | secondguard:walkTo( 198.427155, height, 243.656113) |
---|
[3954] | 143 | |
---|
| 144 | guideProgrammed = true |
---|
| 145 | end |
---|
| 146 | |
---|
| 147 | if secondguard:finalGoalReached() then |
---|
| 148 | return true |
---|
| 149 | end |
---|
| 150 | |
---|
[3945] | 151 | return false |
---|
| 152 | end |
---|
| 153 | |
---|
[3954] | 154 | hangarProgrammed = false |
---|
[3945] | 155 | function goToHangar(timestep) |
---|
| 156 | |
---|
[3964] | 157 | if not hangarProgrammed and prisonerReachedLock then |
---|
| 158 | secondguard:walkTo( 194.153641, height, 244.749863) |
---|
| 159 | secondguard:walkTo( 185.976517, height, 243.876404) |
---|
| 160 | secondguard:walkTo( 179.645737, height, 243.505066) |
---|
| 161 | secondguard:walkTo( 169.583008, height, 244.959457) |
---|
| 162 | secondguard:walkTo( 161.454269, height, 249.422363) |
---|
| 163 | secondguard:walkTo( 158.488998, height, 260.951874) |
---|
| 164 | secondguard:walkTo( 158.228958, height, 272.121582) |
---|
| 165 | secondguard:walkTo( 158.326004, height, 288.892853) |
---|
| 166 | secondguard:walkTo( 158.389069, height, 299.792603) |
---|
| 167 | secondguard:walkTo( 158.437561, height, 308.174896) |
---|
| 168 | secondguard:walkTo( 158.479034, height, 315.341095) |
---|
| 169 | secondguard:walkTo( 158.542801, height, 326.362518) |
---|
| 170 | secondguard:walkTo( 158.621414, height, 339.950256) |
---|
| 171 | secondguard:walkTo( 158.664566, height, 347.408417) |
---|
| 172 | secondguard:walkTo( 158.737900, height, 360.080902) |
---|
| 173 | secondguard:walkTo( 158.795013, height, 369.950531) |
---|
| 174 | secondguard:walkTo( 158.857086, height, 380.676056) |
---|
| 175 | secondguard:walkTo( 158.935440, height, 394.219177) |
---|
| 176 | secondguard:walkTo( 158.984039, height, 402.618896) |
---|
| 177 | secondguard:walkTo( 159.035522, height, 411.518219) |
---|
| 178 | secondguard:walkTo( 159.089432, height, 420.837036) |
---|
| 179 | secondguard:walkTo( 159.143021, height, 430.104523) |
---|
| 180 | secondguard:walkTo( 159.203644, height, 440.579224) |
---|
| 181 | secondguard:walkTo( 159.257263, height, 449.841522) |
---|
| 182 | secondguard:walkTo( 159.304810, height, 458.057617) |
---|
| 183 | secondguard:walkTo( 159.351440, height, 466.113068) |
---|
| 184 | secondguard:walkTo( 160.060013, height, 482.411865) |
---|
| 185 | secondguard:walkTo( 161.352600, height, 488.302185) |
---|
| 186 | secondguard:walkTo( 174.254333, height, 503.439209) |
---|
| 187 | secondguard:walkTo( 181.668213, height, 506.381195) |
---|
| 188 | secondguard:walkTo( 189.177277, height, 508.729156) |
---|
| 189 | secondguard:walkTo( 213.465332, height, 512.184326) |
---|
| 190 | secondguard:walkTo( 223.635010, height, 512.920715) |
---|
| 191 | secondguard:walkTo( 233.668503, height, 513.374512) |
---|
| 192 | secondguard:walkTo( 448.702118, height, 512.187744) |
---|
| 193 | secondguard:walkTo( 477.701050, height, 511.587463) |
---|
| 194 | secondguard:walkTo( 525.645752, height, 511.139526) |
---|
| 195 | secondguard:walkTo( 559.871216, height, 510.819763) |
---|
| 196 | secondguard:walkTo( 596.801941, height, 510.632080) |
---|
| 197 | secondguard:walkTo( 640.160767, height, 510.906891) |
---|
| 198 | secondguard:walkTo( 684.745239, height, 510.429138) |
---|
| 199 | secondguard:walkTo( 706.457214, height, 508.596039) |
---|
| 200 | secondguard:walkTo( 718.750916, height, 507.558044) |
---|
| 201 | secondguard:walkTo( 728.147827, height, 506.649780) |
---|
| 202 | secondguard:walkTo( 743.581970, height, 502.185822) |
---|
| 203 | secondguard:walkTo( 752.977234, height, 495.788635) |
---|
| 204 | secondguard:walkTo( 759.201721, height, 483.407104) |
---|
| 205 | secondguard:walkTo( 761.196167, height, 461.130798) |
---|
| 206 | secondguard:walkTo( 762.335449, height, 398.166901) |
---|
| 207 | secondguard:walkTo( 762.908691, height, 366.482208) |
---|
| 208 | secondguard:walkTo( 763.506409, height, 333.456848) |
---|
| 209 | secondguard:walkTo( 764.330750, height, 287.894409) |
---|
| 210 | secondguard:walkTo( 767.909790, height, 194.910492) |
---|
| 211 | secondguard:walkTo( 770.649231, height, 122.865265) |
---|
| 212 | secondguard:walkTo( 770.102112, height, 44.244534) |
---|
| 213 | secondguard:walkTo( 767.269775, height, -37.871273) |
---|
| 214 | secondguard:walkTo( 763.989197, height, -132.996460) |
---|
| 215 | secondguard:walkTo( 755.274231, height, -217.520859) |
---|
| 216 | secondguard:walkTo( 739.636230, height, -307.869354) |
---|
| 217 | secondguard:walkTo( 722.792725, height, -390.075226) |
---|
| 218 | secondguard:walkTo( 702.582275, height, -475.155273) |
---|
| 219 | secondguard:walkTo( 687.325012, height, -551.699036) |
---|
| 220 | secondguard:walkTo( 681.873169, height, -628.924316) |
---|
| 221 | secondguard:walkTo( 679.997437, height, -708.013794) |
---|
| 222 | secondguard:walkTo( 681.080933, height, -772.108887) |
---|
| 223 | secondguard:walkTo( 681.686035, height, -845.449524) |
---|
| 224 | secondguard:walkTo( 682.188538, height, -906.434998) |
---|
| 225 | secondguard:walkTo( 682.669800, height, -964.887085) |
---|
| 226 | secondguard:walkTo( 684.829895, height, -1023.870117) |
---|
| 227 | secondguard:walkTo( 690.728516, height, -1069.400146) |
---|
| 228 | secondguard:walkTo( 695.965027, height, -1097.353149) |
---|
| 229 | secondguard:walkTo( 701.128540, height, -1118.496216) |
---|
| 230 | secondguard:walkTo( 708.865234, height, -1144.444214) |
---|
| 231 | secondguard:walkTo( 724.753845, height, -1192.741699) |
---|
| 232 | secondguard:walkTo( 737.665771, height, -1230.398560) |
---|
| 233 | secondguard:walkTo( 741.520081, height, -1241.704712) |
---|
| 234 | secondguard:walkTo( 756.537842, height, -1287.260376) |
---|
| 235 | secondguard:walkTo( 764.046631, height, -1310.927002) |
---|
| 236 | secondguard:walkTo( 769.402771, height, -1342.806152) |
---|
| 237 | secondguard:walkTo( 772.158691, height, -1363.218750) |
---|
| 238 | secondguard:walkTo( 772.599426, height, -1374.571899) |
---|
| 239 | secondguard:walkTo( 771.977844, height, -1390.778320) |
---|
| 240 | secondguard:walkTo( 771.576355, height, -1401.246826) |
---|
| 241 | secondguard:walkTo( 770.982666, height, -1423.905273) |
---|
| 242 | secondguard:walkTo( 770.952637, height, -1429.344360) |
---|
| 243 | secondguard:walkTo( 770.912476, height, -1436.589966) |
---|
| 244 | secondguard:walkTo( 770.880249, height, -1442.399536) |
---|
| 245 | secondguard:walkTo( 770.847107, height, -1448.385376) |
---|
| 246 | secondguard:walkTo( 770.785339, height, -1454.349365) |
---|
| 247 | secondguard:walkTo( 768.858459, height, -1464.382080) |
---|
| 248 | secondguard:walkTo( 767.639709, height, -1469.028809) |
---|
| 249 | secondguard:walkTo( 765.099487, height, -1476.370605) |
---|
| 250 | secondguard:walkTo( 762.003601, height, -1484.767456) |
---|
| 251 | secondguard:walkTo( 758.787231, height, -1492.394287) |
---|
| 252 | secondguard:walkTo( 755.135986, height, -1496.482788) |
---|
| 253 | secondguard:walkTo( 752.631165, height, -1498.550049) |
---|
| 254 | secondguard:walkTo( 746.021912, height, -1502.547485) |
---|
| 255 | secondguard:walkTo( 739.376099, height, -1505.427734) |
---|
| 256 | secondguard:walkTo( 731.429199, height, -1507.691162) |
---|
| 257 | secondguard:walkTo( 719.202393, height, -1510.812622) |
---|
| 258 | secondguard:walkTo( 716.329712, height, -1511.546021) |
---|
| 259 | secondguard:walkTo( 711.301514, height, -1512.674438) |
---|
| 260 | secondguard:walkTo( 702.414124, height, -1514.126099) |
---|
| 261 | secondguard:walkTo( 695.724304, height, -1515.173218) |
---|
| 262 | secondguard:walkTo( 576.522278, height, -1521.146362) |
---|
| 263 | secondguard:walkTo( 542.552246, height, -1522.204712) |
---|
| 264 | secondguard:walkTo( 499.907288, height, -1524.441772) |
---|
| 265 | secondguard:walkTo( 461.101288, height, -1525.987915) |
---|
| 266 | secondguard:walkTo( 417.154602, height, -1526.579102) |
---|
| 267 | secondguard:walkTo( 367.752686, height, -1527.168091) |
---|
| 268 | secondguard:walkTo( 322.209106, height, -1527.709473) |
---|
| 269 | secondguard:walkTo( 273.998047, height, -1528.283447) |
---|
| 270 | secondguard:walkTo( 234.330612, height, -1528.756348) |
---|
| 271 | secondguard:walkTo( 188.730209, height, -1529.299438) |
---|
| 272 | secondguard:walkTo( 140.078659, height, -1529.880249) |
---|
| 273 | secondguard:walkTo( 105.882103, height, -1530.287109) |
---|
| 274 | secondguard:walkTo( 71.860947, height, -1532.856079) |
---|
| 275 | secondguard:walkTo( 39.777569, height, -1541.485596) |
---|
| 276 | secondguard:walkTo( 13.919314, height, -1565.188110) |
---|
| 277 | secondguard:walkTo( -0.632493, height, -1604.602783) |
---|
| 278 | secondguard:walkTo( -2.103141, height, -1639.236694) |
---|
| 279 | secondguard:walkTo( 0.498238, height, -1674.846558) |
---|
| 280 | secondguard:walkTo( 2.861493, height, -1705.131958) |
---|
[3954] | 281 | |
---|
| 282 | hangarProgrammed = true |
---|
| 283 | end |
---|
| 284 | |
---|
[3965] | 285 | guardX = secondguard:getAbsCoorX() |
---|
| 286 | guardY = secondguard:getAbsCoorY() |
---|
| 287 | guardZ = secondguard:getAbsCoorZ() |
---|
| 288 | |
---|
| 289 | if dist( guardX,guardY,guardZ, 2.861493, 29, -1705.131958) < 60 then |
---|
[3954] | 290 | return true |
---|
| 291 | end |
---|
| 292 | |
---|
[3945] | 293 | return false |
---|
[3954] | 294 | |
---|
[3945] | 295 | end |
---|
| 296 | |
---|
[3965] | 297 | time = 2 |
---|
[3945] | 298 | function tick(timestep) |
---|
[3946] | 299 | --io.write("Secondguard called \n") |
---|
| 300 | |
---|
| 301 | observePrisoner() |
---|
[3964] | 302 | observeGuard() |
---|
[3945] | 303 | |
---|
| 304 | if not allOk then |
---|
[3951] | 305 | cellReached = goToCell(timestep) |
---|
[3945] | 306 | end |
---|
| 307 | |
---|
[3965] | 308 | --do talking |
---|
| 309 | if cellReached then |
---|
| 310 | time = time - timestep |
---|
| 311 | end |
---|
| 312 | |
---|
| 313 | |
---|
| 314 | if time < 0 then |
---|
| 315 | |
---|
[3951] | 316 | if cellReached and not guidePositionReached then |
---|
[3945] | 317 | guidePositionReached = goToGuidePosition(timestep) |
---|
| 318 | end |
---|
| 319 | |
---|
[3964] | 320 | if guidePositionReached and not hangarReached then |
---|
[3945] | 321 | hangarReached = goToHangar(timestep) |
---|
| 322 | end |
---|
| 323 | |
---|
| 324 | if hangarReached then |
---|
| 325 | return true |
---|
| 326 | end |
---|
| 327 | |
---|
[3965] | 328 | |
---|
| 329 | end |
---|
| 330 | |
---|
| 331 | |
---|
[3945] | 332 | return false |
---|
| 333 | end |
---|