annotate code/gameState.lm @ 85:f420fabd0e44 default tip

One last README change
author Michael Pavone <pavone@retrodev.com>
date Mon, 28 Jul 2014 04:42:24 -0700
parents 8f6ade456edf
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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: {
64
8f6ade456edf bugfixes to runtime errors of gameState.lm
William Morgan <billjunk@mrgn.org>
parents: 62
diff changeset
46 ret <- input
62
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{
64
8f6ade456edf bugfixes to runtime errors of gameState.lm
William Morgan <billjunk@mrgn.org>
parents: 62
diff changeset
80 print: #[2 ghosts]
46
d631e68a45d5 separated out grid functions for reuse inside gameState.lm
William Morgan <billjunk@mrgn.org>
parents: 45
diff changeset
81 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
82 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
83 lambdamanStartDir <- dirDown
c17380c8bac3 ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents: 54
diff changeset
84 lambdamanPos <- lambdamanStartPos
c17380c8bac3 ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents: 54
diff changeset
85 lambdamanDir <- lambdamanStartDir
46
d631e68a45d5 separated out grid functions for reuse inside gameState.lm
William Morgan <billjunk@mrgn.org>
parents: 45
diff changeset
86 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
87 pillCount <- 50 // TODO count pills during parse
45
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
88
53
2c790eabe379 fixed bug with lambdaman/lambdaMan typo in gameState.
William Morgan <billjunk@mrgn.org>
parents: 52
diff changeset
89 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
90 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
91
64
8f6ade456edf bugfixes to runtime errors of gameState.lm
William Morgan <billjunk@mrgn.org>
parents: 62
diff changeset
92 print: 30
62
c17380c8bac3 ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents: 54
diff changeset
93 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
94 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
95 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
96 ghostModeStandard <- 0
c17380c8bac3 ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents: 54
diff changeset
97 ghostModeFright <- 1
c17380c8bac3 ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents: 54
diff changeset
98 ghostModeinvisble <- 2
c17380c8bac3 ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents: 54
diff changeset
99 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
100 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
101 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
102 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
103 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
104 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
105 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
106 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
107 ret <- 0
c17380c8bac3 ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents: 54
diff changeset
108 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
109 ret <- ticksPerMove
c17380c8bac3 ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents: 54
diff changeset
110 } else: {
c17380c8bac3 ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents: 54
diff changeset
111 ret <- frightTicksPerMove
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 ret
c17380c8bac3 ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents: 54
diff changeset
114 }
c17380c8bac3 ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents: 54
diff changeset
115
53
2c790eabe379 fixed bug with lambdaman/lambdaMan typo in gameState.
William Morgan <billjunk@mrgn.org>
parents: 52
diff changeset
116
45
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
117 makeEventType <- :lagTick isMovement behavior{
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
118 print: 12
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
119 :curTick {
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
120 print: 11
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
121 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
122 #[expireTick isMovement :events {behavior: expireTick events}]
45
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
123 }
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
124 }
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
125
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
126 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
127 777 print
46
d631e68a45d5 separated out grid functions for reuse inside gameState.lm
William Morgan <billjunk@mrgn.org>
parents: 45
diff changeset
128 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
129 events
45
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
130 }
53
2c790eabe379 fixed bug with lambdaman/lambdaMan typo in gameState.
William Morgan <billjunk@mrgn.org>
parents: 52
diff changeset
131
62
c17380c8bac3 ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents: 54
diff changeset
132 /*
c17380c8bac3 ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents: 54
diff changeset
133 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
134 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
135
c17380c8bac3 ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents: 54
diff changeset
136 // 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
137 fruit <- :tick { }
c17380c8bac3 ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents: 54
diff changeset
138 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
139 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
140 fruit1Expires | events
c17380c8bac3 ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents: 54
diff changeset
141 }
c17380c8bac3 ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents: 54
diff changeset
142 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
143 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
144 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
145 */
c17380c8bac3 ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents: 54
diff changeset
146
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
147 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
148 print: 20
2c790eabe379 fixed bug with lambdaman/lambdaMan typo in gameState.
William Morgan <billjunk@mrgn.org>
parents: 52
diff changeset
149 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
150 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
151 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
152 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
153 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
154 } else: { }
62
c17380c8bac3 ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents: 54
diff changeset
155
c17380c8bac3 ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents: 54
diff changeset
156 ret <- 0
c17380c8bac3 ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents: 54
diff changeset
157 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
158 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
159 } else: {
c17380c8bac3 ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents: 54
diff changeset
160 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
161 }
62
c17380c8bac3 ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents: 54
diff changeset
162 ret
46
d631e68a45d5 separated out grid functions for reuse inside gameState.lm
William Morgan <billjunk@mrgn.org>
parents: 45
diff changeset
163 }
47
115695e42307 gamestate incremental progress, but does not compile at the moment. sleep time.
William Morgan <billjunk@mrgn.org>
parents: 46
diff changeset
164
62
c17380c8bac3 ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents: 54
diff changeset
165 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
166 print: 21
c17380c8bac3 ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents: 54
diff changeset
167 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
168 #[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
169 nextExpire <- 0
c17380c8bac3 ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents: 54
diff changeset
170 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
171 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
172 legalChoice <- dir
c17380c8bac3 ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents: 54
diff changeset
173 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
174 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
175 legalChoice <- choice
c17380c8bac3 ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents: 54
diff changeset
176 } else: { }
c17380c8bac3 ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents: 54
diff changeset
177
c17380c8bac3 ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents: 54
diff changeset
178 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
179 newDir <- 0
c17380c8bac3 ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents: 54
diff changeset
180 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
181 newTile <- 0
c17380c8bac3 ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents: 54
diff changeset
182 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
183 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
184 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
185 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
186 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
187 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
188 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
189 attempts <- []
c17380c8bac3 ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents: 54
diff changeset
190 } else: {
c17380c8bac3 ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents: 54
diff changeset
191 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
192 }
c17380c8bac3 ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents: 54
diff changeset
193 }
c17380c8bac3 ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents: 54
diff changeset
194
c17380c8bac3 ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents: 54
diff changeset
195 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
196 ghost
c17380c8bac3 ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents: 54
diff changeset
197 }
c17380c8bac3 ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents: 54
diff changeset
198 (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
199 }]
47
115695e42307 gamestate incremental progress, but does not compile at the moment. sleep time.
William Morgan <billjunk@mrgn.org>
parents: 46
diff changeset
200 }
45
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
201
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
202 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
203 print: #[23 tick isMove events]
45
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
204 event <- 0
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
205 eventTick <- 0
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
206 eventIsMove <- 0
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
207 eventLam <- 0
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
208
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
209 unexpired <- []
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
210 while: { not: (events empty?) } do: {
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
211 event <- events value
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
212 eventTick <- event value
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
213 eventIsMove <- (event tail) value
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
214 print: 17
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
215 if: ( ( eventTick = tick ) myAnd: ( eventIsMove = isMove ) ) {
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
216 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
217 unexpired <- eventLam: unexpired
45
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
218 } else: {
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
219 unexpired <- event | unexpired
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 events <- events tail
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
222 }
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
223 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
224 unexpired
45
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
225 }
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
226
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
227 executeTick <- :tick events {
45
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
228 print: 14
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
229 // 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
230 events <- executeEvents: tick 1 events
45
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
231
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
232 print: 15
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
233 // 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
234 events <- executeEvents: tick 0 events
45
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
235
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
236 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
237 // 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
238
45
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
239
62
c17380c8bac3 ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents: 54
diff changeset
240 // 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
241
c17380c8bac3 ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents: 54
diff changeset
242 ret <- 0
46
d631e68a45d5 separated out grid functions for reuse inside gameState.lm
William Morgan <billjunk@mrgn.org>
parents: 45
diff changeset
243 if: pillCount = 0 {
d631e68a45d5 separated out grid functions for reuse inside gameState.lm
William Morgan <billjunk@mrgn.org>
parents: 45
diff changeset
244 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
245 ret <- []
46
d631e68a45d5 separated out grid functions for reuse inside gameState.lm
William Morgan <billjunk@mrgn.org>
parents: 45
diff changeset
246 } else: {
d631e68a45d5 separated out grid functions for reuse inside gameState.lm
William Morgan <billjunk@mrgn.org>
parents: 45
diff changeset
247 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
248 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
249 } else: {
62
c17380c8bac3 ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents: 54
diff changeset
250 ret <- events
46
d631e68a45d5 separated out grid functions for reuse inside gameState.lm
William Morgan <billjunk@mrgn.org>
parents: 45
diff changeset
251 }
d631e68a45d5 separated out grid functions for reuse inside gameState.lm
William Morgan <billjunk@mrgn.org>
parents: 45
diff changeset
252 }
62
c17380c8bac3 ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents: 54
diff changeset
253 ret
45
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
254 }
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
255
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
256 nextTick <- :events {
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
257 print: 8
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
258 fold: events 0x7FFFFFFF with: :curMin event {
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
259 print: #[9 curMin event]
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
260 eventTick <- event value
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
261 print: 10
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
262 if: eventTick < curMin {
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
263 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
264 } else: { }
45
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
265 curMin
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
266 }
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
267 }
53
2c790eabe379 fixed bug with lambdaman/lambdaMan typo in gameState.
William Morgan <billjunk@mrgn.org>
parents: 52
diff changeset
268
45
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
269 print: 4
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
270 :runUntil {
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
271 tick <- 1
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
272 events <- [
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
273 endOfLives: 0
53
2c790eabe379 fixed bug with lambdaman/lambdaMan typo in gameState.
William Morgan <billjunk@mrgn.org>
parents: 52
diff changeset
274 moveLambdaman: 0
45
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
275 ]
62
c17380c8bac3 ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents: 54
diff changeset
276 ghostIdx <- 0
c17380c8bac3 ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents: 54
diff changeset
277 ghostType <- 0
c17380c8bac3 ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents: 54
diff changeset
278 ghostTick <- 0
c17380c8bac3 ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents: 54
diff changeset
279 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
280 ghostTick <- ghostGetLag: ghostType ghostModeStandard
64
8f6ade456edf bugfixes to runtime errors of gameState.lm
William Morgan <billjunk@mrgn.org>
parents: 62
diff changeset
281 print: 5
62
c17380c8bac3 ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents: 54
diff changeset
282 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
283 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
284 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
285 }
50
57a4bddadd46 added new helper functions to grids. more bugfixes to gameState.lm which compiles.
William Morgan <billjunk@mrgn.org>
parents: 47
diff changeset
286 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
287 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
288 events <- executeTick: tick events
53
2c790eabe379 fixed bug with lambdaman/lambdaMan typo in gameState.
William Morgan <billjunk@mrgn.org>
parents: 52
diff changeset
289 print: 7
2c790eabe379 fixed bug with lambdaman/lambdaMan typo in gameState.
William Morgan <billjunk@mrgn.org>
parents: 52
diff changeset
290 tick <- events nextTick
45
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 }
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
294
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
295 step <- :myState world {
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
296 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
297 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
298 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
299 })
57a4bddadd46 added new helper functions to grids. more bugfixes to gameState.lm which compiles.
William Morgan <billjunk@mrgn.org>
parents: 47
diff changeset
300
62
c17380c8bac3 ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents: 54
diff changeset
301 world
c17380c8bac3 ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents: 54
diff changeset
302
64
8f6ade456edf bugfixes to runtime errors of gameState.lm
William Morgan <billjunk@mrgn.org>
parents: 62
diff changeset
303 ghostsList <- ((world tail) tail) value
8f6ade456edf bugfixes to runtime errors of gameState.lm
William Morgan <billjunk@mrgn.org>
parents: 62
diff changeset
304 ghosts <- makeTree: ghostsList
8f6ade456edf bugfixes to runtime errors of gameState.lm
William Morgan <billjunk@mrgn.org>
parents: 62
diff changeset
305 ticker <- makeTicker: grid ghosts
8f6ade456edf bugfixes to runtime errors of gameState.lm
William Morgan <billjunk@mrgn.org>
parents: 62
diff changeset
306 print: 3
45
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
307 ticker: 1000
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
308
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
309 #[0 0]
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
310 }
62
c17380c8bac3 ghost movement compiles. fixed code that relied on if being an expression.
William Morgan <billjunk@mrgn.org>
parents: 54
diff changeset
311
45
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
312 main <- :initWorld ghostCode{
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
313 #[0 step]
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
314 }
64
8f6ade456edf bugfixes to runtime errors of gameState.lm
William Morgan <billjunk@mrgn.org>
parents: 62
diff changeset
315 /*
52
70423511f49d gameState now runs in gcc to completion without runtime errors.
William Morgan <billjunk@mrgn.org>
parents: 50
diff changeset
316 main <- {
70423511f49d gameState now runs in gcc to completion without runtime errors.
William Morgan <billjunk@mrgn.org>
parents: 50
diff changeset
317 print: (step: 0 #[
70423511f49d gameState now runs in gcc to completion without runtime errors.
William Morgan <billjunk@mrgn.org>
parents: 50
diff changeset
318 //grid
70423511f49d gameState now runs in gcc to completion without runtime errors.
William Morgan <billjunk@mrgn.org>
parents: 50
diff changeset
319 [
70423511f49d gameState now runs in gcc to completion without runtime errors.
William Morgan <billjunk@mrgn.org>
parents: 50
diff changeset
320 [0 0 0 0]
70423511f49d gameState now runs in gcc to completion without runtime errors.
William Morgan <billjunk@mrgn.org>
parents: 50
diff changeset
321 [0 2 2 0]
70423511f49d gameState now runs in gcc to completion without runtime errors.
William Morgan <billjunk@mrgn.org>
parents: 50
diff changeset
322 [0 1 0 0]
70423511f49d gameState now runs in gcc to completion without runtime errors.
William Morgan <billjunk@mrgn.org>
parents: 50
diff changeset
323 [0 0 0 0]
70423511f49d gameState now runs in gcc to completion without runtime errors.
William Morgan <billjunk@mrgn.org>
parents: 50
diff changeset
324 ]
70423511f49d gameState now runs in gcc to completion without runtime errors.
William Morgan <billjunk@mrgn.org>
parents: 50
diff changeset
325 //lmstate
70423511f49d gameState now runs in gcc to completion without runtime errors.
William Morgan <billjunk@mrgn.org>
parents: 50
diff changeset
326 #[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
327 //ghost state
70423511f49d gameState now runs in gcc to completion without runtime errors.
William Morgan <billjunk@mrgn.org>
parents: 50
diff changeset
328 []
70423511f49d gameState now runs in gcc to completion without runtime errors.
William Morgan <billjunk@mrgn.org>
parents: 50
diff changeset
329 //fruit state
70423511f49d gameState now runs in gcc to completion without runtime errors.
William Morgan <billjunk@mrgn.org>
parents: 50
diff changeset
330 0
70423511f49d gameState now runs in gcc to completion without runtime errors.
William Morgan <billjunk@mrgn.org>
parents: 50
diff changeset
331 ])
70423511f49d gameState now runs in gcc to completion without runtime errors.
William Morgan <billjunk@mrgn.org>
parents: 50
diff changeset
332 }
64
8f6ade456edf bugfixes to runtime errors of gameState.lm
William Morgan <billjunk@mrgn.org>
parents: 62
diff changeset
333 */
45
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
334 }
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
335