Mercurial > repos > icfp2014
annotate code/ghost2.gq @ 76:47eb447a74cc
Don't chase ghosts we can't catch
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 28 Jul 2014 02:57:56 -0700 |
parents | 10a75a37c0fa |
children |
rev | line source |
---|---|
73
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1 #{ |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2 up <- 0 |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3 right <- 1 |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
4 down <- 2 |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5 left <- 3 |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
6 myIdx <- (me: ) |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
7 lastX <- 0 |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
8 lastY <- 0 |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
9 myX <- 0 |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
10 myY <- 0 |
74
10a75a37c0fa
Make ghost2 try to maintain a specific distance in fright mode rather than always running away
Michael Pavone <pavone@retrodev.com>
parents:
73
diff
changeset
|
11 dist <- 0 |
10a75a37c0fa
Make ghost2 try to maintain a specific distance in fright mode rather than always running away
Michael Pavone <pavone@retrodev.com>
parents:
73
diff
changeset
|
12 distX <- 0 |
10a75a37c0fa
Make ghost2 try to maintain a specific distance in fright mode rather than always running away
Michael Pavone <pavone@retrodev.com>
parents:
73
diff
changeset
|
13 distY <- 0 |
73
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
14 |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
15 getDirX <- :dir startX { |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
16 if: dir = right { |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
17 startX <- startX + 1 |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
18 } else: { |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
19 if: dir = left { |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
20 startX <- startX - 1 |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
21 } |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
22 } |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
23 startX |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
24 } |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
25 |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
26 getDirY <- :dir startY { |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
27 if: dir = up { |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
28 startY <- startY - 1 |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
29 } else: { |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
30 if: dir = down { |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
31 startY <- startY + 1 |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
32 } |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
33 } |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
34 startY |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
35 } |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
36 |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
37 /* |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
38 opDir <- :dir { |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
39 (dir + 2) and: 3 |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
40 } |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
41 */ |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
42 |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
43 goTowardsX:Y <- :targetX targetY { |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
44 myVit <- ghostStatus: myIdx |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
45 myDir <- direction |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
46 |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
47 |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
48 firstChoice <- 0 |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
49 secondChoice <- 0 |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
50 |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
51 if: myX > targetX { |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
52 //ghost is to the right of target |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
53 if: myY > targetY { |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
54 //ghost is below target |
74
10a75a37c0fa
Make ghost2 try to maintain a specific distance in fright mode rather than always running away
Michael Pavone <pavone@retrodev.com>
parents:
73
diff
changeset
|
55 if: distX > distY { |
73
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
56 //target is more left than up |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
57 firstChoice <- left |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
58 secondChoice <- up |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
59 } else: { |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
60 firstChoice <- up |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
61 secondChoice <- left |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
62 } |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
63 } else: { |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
64 //ghost is above or directly to the right of target |
74
10a75a37c0fa
Make ghost2 try to maintain a specific distance in fright mode rather than always running away
Michael Pavone <pavone@retrodev.com>
parents:
73
diff
changeset
|
65 if: distX > distY { |
73
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
66 //target is more left than down |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
67 firstChoice <- left |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
68 secondChoice <- down |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
69 } else: { |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
70 //target is more down than left |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
71 firstChoice <- down |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
72 secondChoice <- left |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
73 } |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
74 } |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
75 } else: { |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
76 //ghost is to the left of or directly above/below target |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
77 if: myY > targetY { |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
78 //ghost is below target |
74
10a75a37c0fa
Make ghost2 try to maintain a specific distance in fright mode rather than always running away
Michael Pavone <pavone@retrodev.com>
parents:
73
diff
changeset
|
79 if: distX > distY { |
73
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
80 //target is more right than up |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
81 firstChoice <- right |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
82 secondChoice <- up |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
83 } else: { |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
84 firstChoice <- up |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
85 secondChoice <- right |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
86 } |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
87 } else: { |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
88 //ghost is above or directly to the left of target |
74
10a75a37c0fa
Make ghost2 try to maintain a specific distance in fright mode rather than always running away
Michael Pavone <pavone@retrodev.com>
parents:
73
diff
changeset
|
89 if: distX > distY { |
73
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
90 //target is more right than down |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
91 firstChoice <- right |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
92 secondChoice <- down |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
93 } else: { |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
94 //target is more down than right |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
95 firstChoice <- down |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
96 secondChoice <- right |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
97 } |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
98 } |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
99 } |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
100 if: myVit = 1 { |
74
10a75a37c0fa
Make ghost2 try to maintain a specific distance in fright mode rather than always running away
Michael Pavone <pavone@retrodev.com>
parents:
73
diff
changeset
|
101 //currently in fright mode, try to run away if we are close to LM |
10a75a37c0fa
Make ghost2 try to maintain a specific distance in fright mode rather than always running away
Michael Pavone <pavone@retrodev.com>
parents:
73
diff
changeset
|
102 if: dist < 16 { |
10a75a37c0fa
Make ghost2 try to maintain a specific distance in fright mode rather than always running away
Michael Pavone <pavone@retrodev.com>
parents:
73
diff
changeset
|
103 firstChoice <- (firstChoice + 2) and: 3 //opDir: firstChoice |
10a75a37c0fa
Make ghost2 try to maintain a specific distance in fright mode rather than always running away
Michael Pavone <pavone@retrodev.com>
parents:
73
diff
changeset
|
104 secondChoice <- (secondChoice + 2) and: 3 //opDir: secondChoice |
10a75a37c0fa
Make ghost2 try to maintain a specific distance in fright mode rather than always running away
Michael Pavone <pavone@retrodev.com>
parents:
73
diff
changeset
|
105 } |
73
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
106 } |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
107 |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
108 |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
109 |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
110 tmp <- 0 |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
111 i <- 0 |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
112 fail <- 0 |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
113 while: { i < 3} do: { |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
114 targetX <- getDirX: firstChoice myX |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
115 targetY <- getDirY: firstChoice myY |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
116 |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
117 if: (mapContentsAt: targetX targetY) - 1 > 4 { |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
118 //first choice is a wall or ghost start pos |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
119 tmp <- firstChoice |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
120 firstChoice <- secondChoice |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
121 secondChoice <- (firstChoice + 2) and: 3 //opDir: firstChoice |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
122 i <- i + 1 |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
123 } else: { |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
124 if: firstChoice = ( (myDir + 2) and: 3 /*opDir: myDir*/) { |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
125 //first choice is backwards |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
126 tmp <- firstChoice |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
127 firstChoice <- secondChoice |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
128 secondChoice <- (firstChoice + 2) and: 3 //opDir: firstChoice |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
129 i <- i + 1 |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
130 } else: { |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
131 i <- 3 |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
132 } |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
133 } |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
134 } |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
135 direction!: firstChoice |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
136 |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
137 0 |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
138 } |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
139 |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
140 //"wingman" - tries to surround lambda man |
74
10a75a37c0fa
Make ghost2 try to maintain a specific distance in fright mode rather than always running away
Michael Pavone <pavone@retrodev.com>
parents:
73
diff
changeset
|
141 //by picking a position sideways of his current direction |
73
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
142 main <- { |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
143 lmX <- lambdamanPos: |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
144 lmY <- yCoord |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
145 myX <- ghostPos: myIdx |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
146 myY <- yCoord |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
147 diffX <- 0 |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
148 diffY <- 0 |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
149 |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
150 if: notFirst? = 1 { |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
151 diffX <- lmX - lastX |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
152 diffY <- lmY - lastY |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
153 } |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
154 lastX <- lmX |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
155 lastY <- lmY |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
156 |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
157 distX <- myX - lmX |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
158 if: distX < 0 { |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
159 distX <- 0 - distX |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
160 } |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
161 distY <- myY - lmY |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
162 if: distY < 0 { |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
163 distY <- 0 - distX |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
164 } |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
165 dist <- distX + distY |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
166 if: dist < 8 { |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
167 diffX <- 0 |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
168 diffY <- 0 |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
169 } |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
170 |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
171 lmX <- (lmX + diffY) + diffY |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
172 lmY <- (lmY + diffX) + diffX |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
173 |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
174 goTowardsX: lmX Y: lmY |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
175 |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
176 } |
91e7a30a9e27
Unsuccessful attempt at improving ghost performance with a wingman ghost
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
177 } |