Mercurial > repos > icfp2014
annotate code/gameState.lm @ 62:c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
author | William Morgan <billjunk@mrgn.org> |
---|---|
date | Mon, 28 Jul 2014 01:47:07 -0700 |
parents | 476cd9eba2be |
children | 8f6ade456edf |
rev | line source |
---|---|
45
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
1 #{ |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
2 import: [ |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
3 length |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
4 reverse |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
5 split:at |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
6 map |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
7 fold:with |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
8 filter |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
9 flatten |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
10 ] from: (module: "ll.lm") |
46
d631e68a45d5
separated out grid functions for reuse inside gameState.lm
William Morgan <billjunk@mrgn.org>
parents:
45
diff
changeset
|
11 |
d631e68a45d5
separated out grid functions for reuse inside gameState.lm
William Morgan <billjunk@mrgn.org>
parents:
45
diff
changeset
|
12 import: [ |
d631e68a45d5
separated out grid functions for reuse inside gameState.lm
William Morgan <billjunk@mrgn.org>
parents:
45
diff
changeset
|
13 makeTree:size |
d631e68a45d5
separated out grid functions for reuse inside gameState.lm
William Morgan <billjunk@mrgn.org>
parents:
45
diff
changeset
|
14 makeTree |
d631e68a45d5
separated out grid functions for reuse inside gameState.lm
William Morgan <billjunk@mrgn.org>
parents:
45
diff
changeset
|
15 get:fromTree:size |
d631e68a45d5
separated out grid functions for reuse inside gameState.lm
William Morgan <billjunk@mrgn.org>
parents:
45
diff
changeset
|
16 get:fromTree |
d631e68a45d5
separated out grid functions for reuse inside gameState.lm
William Morgan <billjunk@mrgn.org>
parents:
45
diff
changeset
|
17 treeMap:size |
d631e68a45d5
separated out grid functions for reuse inside gameState.lm
William Morgan <billjunk@mrgn.org>
parents:
45
diff
changeset
|
18 treeMap |
d631e68a45d5
separated out grid functions for reuse inside gameState.lm
William Morgan <billjunk@mrgn.org>
parents:
45
diff
changeset
|
19 tree:size:update:with |
d631e68a45d5
separated out grid functions for reuse inside gameState.lm
William Morgan <billjunk@mrgn.org>
parents:
45
diff
changeset
|
20 tree:update:with |
d631e68a45d5
separated out grid functions for reuse inside gameState.lm
William Morgan <billjunk@mrgn.org>
parents:
45
diff
changeset
|
21 tree:set:to |
d631e68a45d5
separated out grid functions for reuse inside gameState.lm
William Morgan <billjunk@mrgn.org>
parents:
45
diff
changeset
|
22 ] from: (module: "tree.lm") |
d631e68a45d5
separated out grid functions for reuse inside gameState.lm
William Morgan <billjunk@mrgn.org>
parents:
45
diff
changeset
|
23 |
d631e68a45d5
separated out grid functions for reuse inside gameState.lm
William Morgan <billjunk@mrgn.org>
parents:
45
diff
changeset
|
24 import: [ |
d631e68a45d5
separated out grid functions for reuse inside gameState.lm
William Morgan <billjunk@mrgn.org>
parents:
45
diff
changeset
|
25 grid:get |
d631e68a45d5
separated out grid functions for reuse inside gameState.lm
William Morgan <billjunk@mrgn.org>
parents:
45
diff
changeset
|
26 grid:update:with |
d631e68a45d5
separated out grid functions for reuse inside gameState.lm
William Morgan <billjunk@mrgn.org>
parents:
45
diff
changeset
|
27 grid:set:to |
50
57a4bddadd46
added new helper functions to grids. more bugfixes to gameState.lm which compiles.
William Morgan <billjunk@mrgn.org>
parents:
47
diff
changeset
|
28 gridMaxX |
57a4bddadd46
added new helper functions to grids. more bugfixes to gameState.lm which compiles.
William Morgan <billjunk@mrgn.org>
parents:
47
diff
changeset
|
29 gridMaxY |
57a4bddadd46
added new helper functions to grids. more bugfixes to gameState.lm which compiles.
William Morgan <billjunk@mrgn.org>
parents:
47
diff
changeset
|
30 gridArea |
46
d631e68a45d5
separated out grid functions for reuse inside gameState.lm
William Morgan <billjunk@mrgn.org>
parents:
45
diff
changeset
|
31 grid:inBounds? |
62
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
32 grid:get:withDefault |
46
d631e68a45d5
separated out grid functions for reuse inside gameState.lm
William Morgan <billjunk@mrgn.org>
parents:
45
diff
changeset
|
33 calcPos |
d631e68a45d5
separated out grid functions for reuse inside gameState.lm
William Morgan <billjunk@mrgn.org>
parents:
45
diff
changeset
|
34 ] from: (module: "grid.lm") |
45
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
35 |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
36 myAnd <- :a b { |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
37 // only ones and zeros |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
38 (a + b) = 2 |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
39 } |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
40 |
62
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
41 poorMod <- :input mod { |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
42 ret <- input |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
43 if: input >= mod { |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
44 ret <- input - mod |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
45 } else: { |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
46 ret input |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
47 } |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
48 ret |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
49 } |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
50 |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
51 tupGet <- :cell idx size { |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
52 ret <- 0 |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
53 if: idx = 0 { |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
54 ret <- cell value |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
55 } else: { |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
56 if: size = 1 { |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
57 ret <- cell tail |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
58 } else: { // warning, out-of-bounds idx will return a value! |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
59 ret <- tupGet: (cell tail) (idx - 1) (size - 1) |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
60 } |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
61 } |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
62 ret |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
63 } |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
64 |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
65 tileWall <- 0 |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
66 tileEmpty <- 1 |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
67 tilePill <- 2 |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
68 tilePower <- 3 |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
69 tileFruit <- 4 |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
70 tileLm <- 5 |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
71 tileGhost <- 6 |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
72 |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
73 dirUp <- 0 |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
74 dirRight <- 1 |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
75 dirDown <- 2 |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
76 dirLeft <- 3 |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
77 dirFlipped <- :dir {(dir + 2) poorMod: 4} |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
78 |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
79 makeTicker <- :mapGrid :ghosts{ |
46
d631e68a45d5
separated out grid functions for reuse inside gameState.lm
William Morgan <billjunk@mrgn.org>
parents:
45
diff
changeset
|
80 lives <- 3 |
62
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
81 lambdamanStartPos <- #[5 5] // TODO grab during parse or write {grid: mapGrid find: tileLm} |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
82 lambdamanStartDir <- dirDown |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
83 lambdamanPos <- lambdamanStartPos |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
84 lambdamanDir <- lambdamanStartDir |
46
d631e68a45d5
separated out grid functions for reuse inside gameState.lm
William Morgan <billjunk@mrgn.org>
parents:
45
diff
changeset
|
85 win <- 0 |
62
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
86 pillCount <- 50 // TODO count pills during parse |
45
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
87 |
53
2c790eabe379
fixed bug with lambdaman/lambdaMan typo in gameState.
William Morgan <billjunk@mrgn.org>
parents:
52
diff
changeset
|
88 isFood <- :tile { (2 <= tile) myAnd: (tile <= 4) } |
62
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
89 getLambdamanChoice <- {0} // TODO ai hookups |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
90 |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
91 ghostPopulation <- ghosts value |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
92 ghostChoosers <- #[{0} {0} {0} {0}] // TODO ai hookups |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
93 ghostChoice <- :ghostIdx{tupGet: ghostChoosers ghostIdx 4} |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
94 ghostModeStandard <- 0 |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
95 ghostModeFright <- 1 |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
96 ghostModeinvisble <- 2 |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
97 ghostVitality <- :ghost {ghost value} |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
98 ghostPos <- :ghost {(ghost tail) value} |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
99 ghostSetPos <- :ghost pos { #[(ghost ghostVitality) pos (ghost ghostDir)] } |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
100 ghostDir <- :ghost {(ghost tail) tail} |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
101 ghostSetDir <- :ghost dir { #[(ghost ghostVitality) (ghost ghostPos) dir] } |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
102 ghostGetLag <- :ghostType vitality{ |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
103 ticksPerMove <- 130 + 2 * ghostType |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
104 frightTicksPerMove <- ticksPerMove + 65 + ghostType |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
105 ret <- 0 |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
106 if: vitality = ghostModeFright { |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
107 ret <- ticksPerMove |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
108 } else: { |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
109 ret <- frightTicksPerMove |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
110 } |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
111 ret |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
112 } |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
113 |
53
2c790eabe379
fixed bug with lambdaman/lambdaMan typo in gameState.
William Morgan <billjunk@mrgn.org>
parents:
52
diff
changeset
|
114 |
45
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
115 makeEventType <- :lagTick isMovement behavior{ |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
116 print: 12 |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
117 :curTick { |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
118 print: 11 |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
119 expireTick <- curTick + lagTick |
54
476cd9eba2be
fixed event system with refactor to remove gamestate passing. much more simple, less pure. runs correctly in simulator.
William Morgan <billjunk@mrgn.org>
parents:
53
diff
changeset
|
120 #[expireTick isMovement :events {behavior: expireTick events}] |
45
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
121 } |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
122 } |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
123 |
54
476cd9eba2be
fixed event system with refactor to remove gamestate passing. much more simple, less pure. runs correctly in simulator.
William Morgan <billjunk@mrgn.org>
parents:
53
diff
changeset
|
124 endOfLives <- makeEventType: (127 * (mapGrid gridArea) * 16) 0 :tick events { |
62
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
125 777 print |
46
d631e68a45d5
separated out grid functions for reuse inside gameState.lm
William Morgan <billjunk@mrgn.org>
parents:
45
diff
changeset
|
126 lives <- 0 |
54
476cd9eba2be
fixed event system with refactor to remove gamestate passing. much more simple, less pure. runs correctly in simulator.
William Morgan <billjunk@mrgn.org>
parents:
53
diff
changeset
|
127 events |
45
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
128 } |
53
2c790eabe379
fixed bug with lambdaman/lambdaMan typo in gameState.
William Morgan <billjunk@mrgn.org>
parents:
52
diff
changeset
|
129 |
62
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
130 /* |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
131 TODO the rest of the easy action events |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
132 frightModeDeactivate <- (127 * 20) 0 |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
133 |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
134 // fruit must be a lambda that can be given a time |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
135 fruit <- :tick { } |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
136 fruit1Appears <- makeEventType: (127 * 200) 0 :events { |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
137 fruit <- :tick{80} |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
138 fruit1Expires | events |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
139 } |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
140 fruit2Appears <- (127 * 400) 0 |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
141 fruit1Expires <- (127 * 280) 0 |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
142 fruit2Expires <- (127 * 480) 0 |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
143 */ |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
144 |
54
476cd9eba2be
fixed event system with refactor to remove gamestate passing. much more simple, less pure. runs correctly in simulator.
William Morgan <billjunk@mrgn.org>
parents:
53
diff
changeset
|
145 moveLambdaman <- makeEventType: 127 1 :tick events { |
53
2c790eabe379
fixed bug with lambdaman/lambdaMan typo in gameState.
William Morgan <billjunk@mrgn.org>
parents:
52
diff
changeset
|
146 print: 20 |
2c790eabe379
fixed bug with lambdaman/lambdaMan typo in gameState.
William Morgan <billjunk@mrgn.org>
parents:
52
diff
changeset
|
147 move <- getLambdamanChoice: |
47
115695e42307
gamestate incremental progress, but does not compile at the moment. sleep time.
William Morgan <billjunk@mrgn.org>
parents:
46
diff
changeset
|
148 newPos <- (calcPos: move lambdamanPos) |
62
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
149 newTile <- grid: mapGrid get: newPos withDefault: tileWall |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
150 if: (not: (newTile = tileWall)) { |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
151 lambdamanPos <- newPos |
50
57a4bddadd46
added new helper functions to grids. more bugfixes to gameState.lm which compiles.
William Morgan <billjunk@mrgn.org>
parents:
47
diff
changeset
|
152 } else: { } |
62
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
153 |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
154 ret <- 0 |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
155 if: (newTile isFood) { |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
156 ret <- (moveLambdaman: (tick + 10)) | events |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
157 } else: { |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
158 ret <-(moveLambdaman: tick) | events |
47
115695e42307
gamestate incremental progress, but does not compile at the moment. sleep time.
William Morgan <billjunk@mrgn.org>
parents:
46
diff
changeset
|
159 } |
62
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
160 ret |
46
d631e68a45d5
separated out grid functions for reuse inside gameState.lm
William Morgan <billjunk@mrgn.org>
parents:
45
diff
changeset
|
161 } |
47
115695e42307
gamestate incremental progress, but does not compile at the moment. sleep time.
William Morgan <billjunk@mrgn.org>
parents:
46
diff
changeset
|
162 |
62
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
163 moveGhost <- :lagTick ghostIdx ghostType curTick { |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
164 print: 21 |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
165 expireTick <- curTick + lagTick |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
166 #[expireTick 1 :events { |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
167 nextExpire <- 0 |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
168 tree: ghosts update: ghostIdx with: :ghost { |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
169 dir <- ghostDir: ghost |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
170 legalChoice <- dir |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
171 choice <- ghostChoice: ghostIdx |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
172 if: (not: (choice = (dir dirFlipped))) { |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
173 legalChoice <- choice |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
174 } else: { } |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
175 |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
176 attempts <- [legalChoice dirUp dirDown dirLeft dirRight] |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
177 newDir <- 0 |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
178 newPos <- ghost ghostPos |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
179 newTile <- 0 |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
180 while: {not: (attempts empty?:)} do:{ |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
181 newDir <- attempts value |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
182 newPos <- (calcPos: newDir (ghost ghostPos)) |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
183 newTile <- grid: mapGrid get: newPos withDefault: tileWall |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
184 if: (not: (newTile = tileWall)) { |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
185 ghost ghostSetPos: newPos |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
186 ghost ghostSetDir: newDir |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
187 attempts <- [] |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
188 } else: { |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
189 attempts <- attempts tail |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
190 } |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
191 } |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
192 |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
193 nextExpire <- ghostGetLag: ghostType (ghost ghostVitality) |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
194 ghost |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
195 } |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
196 (moveGhost: nextExpire ghostIdx ghostType expireTick) | events |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
197 }] |
47
115695e42307
gamestate incremental progress, but does not compile at the moment. sleep time.
William Morgan <billjunk@mrgn.org>
parents:
46
diff
changeset
|
198 } |
45
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
199 |
54
476cd9eba2be
fixed event system with refactor to remove gamestate passing. much more simple, less pure. runs correctly in simulator.
William Morgan <billjunk@mrgn.org>
parents:
53
diff
changeset
|
200 executeEvents <- :tick isMove events { |
476cd9eba2be
fixed event system with refactor to remove gamestate passing. much more simple, less pure. runs correctly in simulator.
William Morgan <billjunk@mrgn.org>
parents:
53
diff
changeset
|
201 print: #[23 tick isMove events] |
45
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
202 event <- 0 |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
203 eventTick <- 0 |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
204 eventIsMove <- 0 |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
205 eventLam <- 0 |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
206 |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
207 unexpired <- [] |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
208 while: { not: (events empty?) } do: { |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
209 event <- events value |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
210 eventTick <- event value |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
211 eventIsMove <- (event tail) value |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
212 print: 17 |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
213 if: ( ( eventTick = tick ) myAnd: ( eventIsMove = isMove ) ) { |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
214 eventLam <- ((event tail) tail) |
54
476cd9eba2be
fixed event system with refactor to remove gamestate passing. much more simple, less pure. runs correctly in simulator.
William Morgan <billjunk@mrgn.org>
parents:
53
diff
changeset
|
215 unexpired <- eventLam: unexpired |
45
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
216 } else: { |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
217 unexpired <- event | unexpired |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
218 } |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
219 events <- events tail |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
220 } |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
221 print: 18 |
54
476cd9eba2be
fixed event system with refactor to remove gamestate passing. much more simple, less pure. runs correctly in simulator.
William Morgan <billjunk@mrgn.org>
parents:
53
diff
changeset
|
222 unexpired |
45
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
223 } |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
224 |
54
476cd9eba2be
fixed event system with refactor to remove gamestate passing. much more simple, less pure. runs correctly in simulator.
William Morgan <billjunk@mrgn.org>
parents:
53
diff
changeset
|
225 executeTick <- :tick events { |
45
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
226 print: 14 |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
227 // 1.) movement |
54
476cd9eba2be
fixed event system with refactor to remove gamestate passing. much more simple, less pure. runs correctly in simulator.
William Morgan <billjunk@mrgn.org>
parents:
53
diff
changeset
|
228 events <- executeEvents: tick 1 events |
45
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
229 |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
230 print: 15 |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
231 // 2.) actions |
54
476cd9eba2be
fixed event system with refactor to remove gamestate passing. much more simple, less pure. runs correctly in simulator.
William Morgan <billjunk@mrgn.org>
parents:
53
diff
changeset
|
232 events <- executeEvents: tick 0 events |
45
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
233 |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
234 print: 16 |
62
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
235 // 3.) TODO collide pills powerpills fruit |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
236 |
45
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
237 |
62
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
238 // 4.) TODO ghost collision |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
239 |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
240 ret <- 0 |
46
d631e68a45d5
separated out grid functions for reuse inside gameState.lm
William Morgan <billjunk@mrgn.org>
parents:
45
diff
changeset
|
241 if: pillCount = 0 { |
d631e68a45d5
separated out grid functions for reuse inside gameState.lm
William Morgan <billjunk@mrgn.org>
parents:
45
diff
changeset
|
242 win <- 1 |
62
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
243 ret <- [] |
46
d631e68a45d5
separated out grid functions for reuse inside gameState.lm
William Morgan <billjunk@mrgn.org>
parents:
45
diff
changeset
|
244 } else: { |
d631e68a45d5
separated out grid functions for reuse inside gameState.lm
William Morgan <billjunk@mrgn.org>
parents:
45
diff
changeset
|
245 if: lives = 0 { |
62
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
246 ret <- [] |
54
476cd9eba2be
fixed event system with refactor to remove gamestate passing. much more simple, less pure. runs correctly in simulator.
William Morgan <billjunk@mrgn.org>
parents:
53
diff
changeset
|
247 } else: { |
62
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
248 ret <- events |
46
d631e68a45d5
separated out grid functions for reuse inside gameState.lm
William Morgan <billjunk@mrgn.org>
parents:
45
diff
changeset
|
249 } |
d631e68a45d5
separated out grid functions for reuse inside gameState.lm
William Morgan <billjunk@mrgn.org>
parents:
45
diff
changeset
|
250 } |
62
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
251 ret |
45
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
252 } |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
253 |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
254 nextTick <- :events { |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
255 print: 8 |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
256 fold: events 0x7FFFFFFF with: :curMin event { |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
257 print: #[9 curMin event] |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
258 eventTick <- event value |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
259 print: 10 |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
260 if: eventTick < curMin { |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
261 curMin <- eventTick |
62
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
262 } else: { } |
45
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
263 curMin |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
264 } |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
265 } |
53
2c790eabe379
fixed bug with lambdaman/lambdaMan typo in gameState.
William Morgan <billjunk@mrgn.org>
parents:
52
diff
changeset
|
266 |
45
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
267 print: 4 |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
268 :runUntil { |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
269 tick <- 1 |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
270 events <- [ |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
271 endOfLives: 0 |
53
2c790eabe379
fixed bug with lambdaman/lambdaMan typo in gameState.
William Morgan <billjunk@mrgn.org>
parents:
52
diff
changeset
|
272 moveLambdaman: 0 |
45
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
273 ] |
62
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
274 ghostIdx <- 0 |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
275 ghostType <- 0 |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
276 ghostTick <- 0 |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
277 while: {ghostIdx < ghostPopulation} do: { |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
278 ghostTick <- ghostGetLag: ghostType ghostModeStandard |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
279 events <- (moveGhost: 0 ghostIdx ghostType ghostTick) | events |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
280 ghostIdx <- ghostIdx + 1 |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
281 ghostType <- (ghostType + 1) poorMod: 4 |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
282 } |
54
476cd9eba2be
fixed event system with refactor to remove gamestate passing. much more simple, less pure. runs correctly in simulator.
William Morgan <billjunk@mrgn.org>
parents:
53
diff
changeset
|
283 print: 5 |
50
57a4bddadd46
added new helper functions to grids. more bugfixes to gameState.lm which compiles.
William Morgan <billjunk@mrgn.org>
parents:
47
diff
changeset
|
284 while: {(tick < runUntil) myAnd: (not: (events empty?))} do: { |
54
476cd9eba2be
fixed event system with refactor to remove gamestate passing. much more simple, less pure. runs correctly in simulator.
William Morgan <billjunk@mrgn.org>
parents:
53
diff
changeset
|
285 print: 6 |
476cd9eba2be
fixed event system with refactor to remove gamestate passing. much more simple, less pure. runs correctly in simulator.
William Morgan <billjunk@mrgn.org>
parents:
53
diff
changeset
|
286 events <- executeTick: tick events |
53
2c790eabe379
fixed bug with lambdaman/lambdaMan typo in gameState.
William Morgan <billjunk@mrgn.org>
parents:
52
diff
changeset
|
287 print: 7 |
2c790eabe379
fixed bug with lambdaman/lambdaMan typo in gameState.
William Morgan <billjunk@mrgn.org>
parents:
52
diff
changeset
|
288 tick <- events nextTick |
45
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
289 } |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
290 } |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
291 } |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
292 |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
293 step <- :myState world { |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
294 print: 1 |
50
57a4bddadd46
added new helper functions to grids. more bugfixes to gameState.lm which compiles.
William Morgan <billjunk@mrgn.org>
parents:
47
diff
changeset
|
295 grid <- makeTree: (map: (world value) :row { |
57a4bddadd46
added new helper functions to grids. more bugfixes to gameState.lm which compiles.
William Morgan <billjunk@mrgn.org>
parents:
47
diff
changeset
|
296 makeTree: row |
57a4bddadd46
added new helper functions to grids. more bugfixes to gameState.lm which compiles.
William Morgan <billjunk@mrgn.org>
parents:
47
diff
changeset
|
297 }) |
57a4bddadd46
added new helper functions to grids. more bugfixes to gameState.lm which compiles.
William Morgan <billjunk@mrgn.org>
parents:
47
diff
changeset
|
298 |
62
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
299 world |
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
300 |
50
57a4bddadd46
added new helper functions to grids. more bugfixes to gameState.lm which compiles.
William Morgan <billjunk@mrgn.org>
parents:
47
diff
changeset
|
301 ticker <- makeTicker: grid |
45
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
302 print: 2 |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
303 ticker: 1000 |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
304 print: 3 |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
305 |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
306 #[0 0] |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
307 } |
62
c17380c8bac3
ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents:
54
diff
changeset
|
308 |
52
70423511f49d
gameState now runs in gcc to completion without runtime errors.
William Morgan <billjunk@mrgn.org>
parents:
50
diff
changeset
|
309 /* |
45
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
310 main <- :initWorld ghostCode{ |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
311 #[0 step] |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
312 } |
52
70423511f49d
gameState now runs in gcc to completion without runtime errors.
William Morgan <billjunk@mrgn.org>
parents:
50
diff
changeset
|
313 */ |
70423511f49d
gameState now runs in gcc to completion without runtime errors.
William Morgan <billjunk@mrgn.org>
parents:
50
diff
changeset
|
314 main <- { |
70423511f49d
gameState now runs in gcc to completion without runtime errors.
William Morgan <billjunk@mrgn.org>
parents:
50
diff
changeset
|
315 print: (step: 0 #[ |
70423511f49d
gameState now runs in gcc to completion without runtime errors.
William Morgan <billjunk@mrgn.org>
parents:
50
diff
changeset
|
316 //grid |
70423511f49d
gameState now runs in gcc to completion without runtime errors.
William Morgan <billjunk@mrgn.org>
parents:
50
diff
changeset
|
317 [ |
70423511f49d
gameState now runs in gcc to completion without runtime errors.
William Morgan <billjunk@mrgn.org>
parents:
50
diff
changeset
|
318 [0 0 0 0] |
70423511f49d
gameState now runs in gcc to completion without runtime errors.
William Morgan <billjunk@mrgn.org>
parents:
50
diff
changeset
|
319 [0 2 2 0] |
70423511f49d
gameState now runs in gcc to completion without runtime errors.
William Morgan <billjunk@mrgn.org>
parents:
50
diff
changeset
|
320 [0 1 0 0] |
70423511f49d
gameState now runs in gcc to completion without runtime errors.
William Morgan <billjunk@mrgn.org>
parents:
50
diff
changeset
|
321 [0 0 0 0] |
70423511f49d
gameState now runs in gcc to completion without runtime errors.
William Morgan <billjunk@mrgn.org>
parents:
50
diff
changeset
|
322 ] |
70423511f49d
gameState now runs in gcc to completion without runtime errors.
William Morgan <billjunk@mrgn.org>
parents:
50
diff
changeset
|
323 //lmstate |
70423511f49d
gameState now runs in gcc to completion without runtime errors.
William Morgan <billjunk@mrgn.org>
parents:
50
diff
changeset
|
324 #[0 #[1 2] 2 3 0] |
70423511f49d
gameState now runs in gcc to completion without runtime errors.
William Morgan <billjunk@mrgn.org>
parents:
50
diff
changeset
|
325 //ghost state |
70423511f49d
gameState now runs in gcc to completion without runtime errors.
William Morgan <billjunk@mrgn.org>
parents:
50
diff
changeset
|
326 [] |
70423511f49d
gameState now runs in gcc to completion without runtime errors.
William Morgan <billjunk@mrgn.org>
parents:
50
diff
changeset
|
327 //fruit state |
70423511f49d
gameState now runs in gcc to completion without runtime errors.
William Morgan <billjunk@mrgn.org>
parents:
50
diff
changeset
|
328 0 |
70423511f49d
gameState now runs in gcc to completion without runtime errors.
William Morgan <billjunk@mrgn.org>
parents:
50
diff
changeset
|
329 ]) |
70423511f49d
gameState now runs in gcc to completion without runtime errors.
William Morgan <billjunk@mrgn.org>
parents:
50
diff
changeset
|
330 } |
45
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
331 } |
75f808e60aa8
initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff
changeset
|
332 |