1 | -- Global Variables |
---|
2 | allOk = true |
---|
3 | cellReached = false |
---|
4 | guidePositionReached = false |
---|
5 | prisonerReachedLock = false |
---|
6 | hangarReached = false |
---|
7 | |
---|
8 | |
---|
9 | -- Returns the distance between (x1,x2,x3) and (y1,y2,y3) |
---|
10 | function dist( x1,x2,x3, y1,y2,y3 ) |
---|
11 | |
---|
12 | return math.sqrt( (x1-y1)^2 + (x2-y2)^2 + (x3-y3)^2 ) |
---|
13 | |
---|
14 | end |
---|
15 | |
---|
16 | |
---|
17 | function observeGuard() |
---|
18 | guardX = guard:getAbsCoorX() |
---|
19 | guardY = guard:getAbsCoorY() |
---|
20 | guardZ = guard:getAbsCoorZ() |
---|
21 | |
---|
22 | if dist( guardX,guardY,guardZ,161.76,49,358.87 ) < 60 then |
---|
23 | allOk = false |
---|
24 | end |
---|
25 | |
---|
26 | end |
---|
27 | |
---|
28 | function observePrisoner() |
---|
29 | |
---|
30 | prisonerX = Prisoner:getAbsCoorX() |
---|
31 | prisonerY = Prisoner:getAbsCoorY() |
---|
32 | prisonerZ = Prisoner:getAbsCoorZ() |
---|
33 | |
---|
34 | if dist( prisonerX,prisonerY,prisonerZ,161.76,49,358.87 ) < 60 then |
---|
35 | prisonerReachedLock = true |
---|
36 | end |
---|
37 | |
---|
38 | end |
---|
39 | |
---|
40 | |
---|
41 | function goToCell(timestep) |
---|
42 | |
---|
43 | return false |
---|
44 | end |
---|
45 | |
---|
46 | function goToGuidePosition(timestep) |
---|
47 | |
---|
48 | return false |
---|
49 | end |
---|
50 | |
---|
51 | function goToHangar(timestep) |
---|
52 | |
---|
53 | return false |
---|
54 | end |
---|
55 | |
---|
56 | function tick(timestep) |
---|
57 | --io.write("Secondguard called \n") |
---|
58 | |
---|
59 | observePrisoner() |
---|
60 | |
---|
61 | if not allOk then |
---|
62 | cellReached = goToCell(timestep) |
---|
63 | end |
---|
64 | |
---|
65 | if cellReached and not guidePositionReached then |
---|
66 | guidePositionReached = goToGuidePosition(timestep) |
---|
67 | end |
---|
68 | |
---|
69 | if guidePositionReached and prisonerReachedLock then |
---|
70 | hangarReached = goToHangar(timestep) |
---|
71 | end |
---|
72 | |
---|
73 | if hangarReached then |
---|
74 | return true |
---|
75 | end |
---|
76 | |
---|
77 | return false |
---|
78 | end |
---|