annotate code/gameState.lm @ 75:6df7f6372d29

Small tweak to dotScanner lambda man AI to ignore power pellets when it would be wasteful to eat them
author Michael Pavone <pavone@retrodev.com>
date Mon, 28 Jul 2014 02:12:10 -0700
parents 476cd9eba2be
children c17380c8bac3
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?
d631e68a45d5 separated out grid functions for reuse inside gameState.lm
William Morgan <billjunk@mrgn.org>
parents: 45
diff changeset
32 calcPos
d631e68a45d5 separated out grid functions for reuse inside gameState.lm
William Morgan <billjunk@mrgn.org>
parents: 45
diff changeset
33 ] from: (module: "grid.lm")
45
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
34
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
35 myAnd <- :a b {
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
36 // only ones and zeros
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
37 (a + b) = 2
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
38 }
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
39
50
57a4bddadd46 added new helper functions to grids. more bugfixes to gameState.lm which compiles.
William Morgan <billjunk@mrgn.org>
parents: 47
diff changeset
40 makeTicker <- :mapGrid {
46
d631e68a45d5 separated out grid functions for reuse inside gameState.lm
William Morgan <billjunk@mrgn.org>
parents: 45
diff changeset
41 lives <- 3
47
115695e42307 gamestate incremental progress, but does not compile at the moment. sleep time.
William Morgan <billjunk@mrgn.org>
parents: 46
diff changeset
42 lambdamanPos <- #[5 5]
46
d631e68a45d5 separated out grid functions for reuse inside gameState.lm
William Morgan <billjunk@mrgn.org>
parents: 45
diff changeset
43 win <- 0
d631e68a45d5 separated out grid functions for reuse inside gameState.lm
William Morgan <billjunk@mrgn.org>
parents: 45
diff changeset
44 pillCount <- 50
45
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
45
53
2c790eabe379 fixed bug with lambdaman/lambdaMan typo in gameState.
William Morgan <billjunk@mrgn.org>
parents: 52
diff changeset
46 isFood <- :tile { (2 <= tile) myAnd: (tile <= 4) }
2c790eabe379 fixed bug with lambdaman/lambdaMan typo in gameState.
William Morgan <billjunk@mrgn.org>
parents: 52
diff changeset
47 getLambdamanChoice <- {0}
2c790eabe379 fixed bug with lambdaman/lambdaMan typo in gameState.
William Morgan <billjunk@mrgn.org>
parents: 52
diff changeset
48
45
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
49 makeEventType <- :lagTick isMovement behavior{
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
50 print: 12
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
51 :curTick {
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
52 print: 11
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
53 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
54 #[expireTick isMovement :events {behavior: expireTick events}]
45
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
55 }
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
56 }
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
57
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
58 endOfLives <- makeEventType: (127 * (mapGrid gridArea) * 16) 0 :tick events {
46
d631e68a45d5 separated out grid functions for reuse inside gameState.lm
William Morgan <billjunk@mrgn.org>
parents: 45
diff changeset
59 lives <- 0
45
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
60 777 print
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
61 events
45
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
62 }
53
2c790eabe379 fixed bug with lambdaman/lambdaMan typo in gameState.
William Morgan <billjunk@mrgn.org>
parents: 52
diff changeset
63
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
64 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
65 print: 20
2c790eabe379 fixed bug with lambdaman/lambdaMan typo in gameState.
William Morgan <billjunk@mrgn.org>
parents: 52
diff changeset
66 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
67 newPos <- (calcPos: move lambdamanPos)
50
57a4bddadd46 added new helper functions to grids. more bugfixes to gameState.lm which compiles.
William Morgan <billjunk@mrgn.org>
parents: 47
diff changeset
68 impending <- grid: mapGrid get: newPos
53
2c790eabe379 fixed bug with lambdaman/lambdaMan typo in gameState.
William Morgan <billjunk@mrgn.org>
parents: 52
diff changeset
69 print: 21
47
115695e42307 gamestate incremental progress, but does not compile at the moment. sleep time.
William Morgan <billjunk@mrgn.org>
parents: 46
diff changeset
70 if: (not: (impending = 0)) {
115695e42307 gamestate incremental progress, but does not compile at the moment. sleep time.
William Morgan <billjunk@mrgn.org>
parents: 46
diff changeset
71 lambdamanPos <- impending
50
57a4bddadd46 added new helper functions to grids. more bugfixes to gameState.lm which compiles.
William Morgan <billjunk@mrgn.org>
parents: 47
diff changeset
72 } else: { }
46
d631e68a45d5 separated out grid functions for reuse inside gameState.lm
William Morgan <billjunk@mrgn.org>
parents: 45
diff changeset
73
53
2c790eabe379 fixed bug with lambdaman/lambdaMan typo in gameState.
William Morgan <billjunk@mrgn.org>
parents: 52
diff changeset
74 print: 22
47
115695e42307 gamestate incremental progress, but does not compile at the moment. sleep time.
William Morgan <billjunk@mrgn.org>
parents: 46
diff changeset
75 if: (impending isFood) {
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
76 (moveLambdaman: (tick + 10)) | events
50
57a4bddadd46 added new helper functions to grids. more bugfixes to gameState.lm which compiles.
William Morgan <billjunk@mrgn.org>
parents: 47
diff changeset
77 } else: {
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
78 (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
79 }
46
d631e68a45d5 separated out grid functions for reuse inside gameState.lm
William Morgan <billjunk@mrgn.org>
parents: 45
diff changeset
80 }
47
115695e42307 gamestate incremental progress, but does not compile at the moment. sleep time.
William Morgan <billjunk@mrgn.org>
parents: 46
diff changeset
81
115695e42307 gamestate incremental progress, but does not compile at the moment. sleep time.
William Morgan <billjunk@mrgn.org>
parents: 46
diff changeset
82 /*
115695e42307 gamestate incremental progress, but does not compile at the moment. sleep time.
William Morgan <billjunk@mrgn.org>
parents: 46
diff changeset
83 fruit <- 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
84 fruit1Appears <- makeEventType: (127 * 200) 0 :events {
47
115695e42307 gamestate incremental progress, but does not compile at the moment. sleep time.
William Morgan <billjunk@mrgn.org>
parents: 46
diff changeset
85 fruit <- 80
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
86 fruit1Expires | events
47
115695e42307 gamestate incremental progress, but does not compile at the moment. sleep time.
William Morgan <billjunk@mrgn.org>
parents: 46
diff changeset
87 }
115695e42307 gamestate incremental progress, but does not compile at the moment. sleep time.
William Morgan <billjunk@mrgn.org>
parents: 46
diff changeset
88 fruit2Appears <- (127 * 400) 0
115695e42307 gamestate incremental progress, but does not compile at the moment. sleep time.
William Morgan <billjunk@mrgn.org>
parents: 46
diff changeset
89 fruit1Expires <- (127 * 280) 0
115695e42307 gamestate incremental progress, but does not compile at the moment. sleep time.
William Morgan <billjunk@mrgn.org>
parents: 46
diff changeset
90 fruit2Expires <- (127 * 480) 0
115695e42307 gamestate incremental progress, but does not compile at the moment. sleep time.
William Morgan <billjunk@mrgn.org>
parents: 46
diff changeset
91 moveGhost0 <- 1 //(ghostType, ghostId)!?
115695e42307 gamestate incremental progress, but does not compile at the moment. sleep time.
William Morgan <billjunk@mrgn.org>
parents: 46
diff changeset
92 moveGhost1 <- 1 //(ghostType, ghostId)!?
115695e42307 gamestate incremental progress, but does not compile at the moment. sleep time.
William Morgan <billjunk@mrgn.org>
parents: 46
diff changeset
93 moveGhost2 <- 1 //(ghostType, ghostId)!?
115695e42307 gamestate incremental progress, but does not compile at the moment. sleep time.
William Morgan <billjunk@mrgn.org>
parents: 46
diff changeset
94 moveGhost3 <- 1 //(ghostType, ghostId)!?
115695e42307 gamestate incremental progress, but does not compile at the moment. sleep time.
William Morgan <billjunk@mrgn.org>
parents: 46
diff changeset
95 frightModeDeactivate <- (127 * 20) 0
45
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
96 */
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
97
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
98 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
99 print: #[23 tick isMove events]
45
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
100 event <- 0
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
101 eventTick <- 0
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
102 eventIsMove <- 0
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
103 eventLam <- 0
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
104
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
105 unexpired <- []
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
106 while: { not: (events empty?) } do: {
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
107 event <- events value
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
108 eventTick <- event value
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
109 eventIsMove <- (event tail) value
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
110 print: 17
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
111 if: ( ( eventTick = tick ) myAnd: ( eventIsMove = isMove ) ) {
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
112 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
113 unexpired <- eventLam: unexpired
45
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
114 } else: {
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
115 unexpired <- event | unexpired
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
116 }
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
117 events <- events tail
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
118 }
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
119 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
120 unexpired
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
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
123 executeTick <- :tick events {
45
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
124 // TODO: update fruit countdown for AI input
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
125
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
126 print: 14
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
127 // 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
128 events <- executeEvents: tick 1 events
45
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
129
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
130 print: 15
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
131 // 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
132 events <- executeEvents: tick 0 events
45
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
133
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
134 print: 16
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
135 // 3.) collide pills powerpills fruit
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
136
46
d631e68a45d5 separated out grid functions for reuse inside gameState.lm
William Morgan <billjunk@mrgn.org>
parents: 45
diff changeset
137 if: pillCount = 0 {
d631e68a45d5 separated out grid functions for reuse inside gameState.lm
William Morgan <billjunk@mrgn.org>
parents: 45
diff changeset
138 win <- 1
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
139 []
46
d631e68a45d5 separated out grid functions for reuse inside gameState.lm
William Morgan <billjunk@mrgn.org>
parents: 45
diff changeset
140 } else: {
d631e68a45d5 separated out grid functions for reuse inside gameState.lm
William Morgan <billjunk@mrgn.org>
parents: 45
diff changeset
141 if: 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
142 []
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
143 } else: {
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
144 events
46
d631e68a45d5 separated out grid functions for reuse inside gameState.lm
William Morgan <billjunk@mrgn.org>
parents: 45
diff changeset
145 }
d631e68a45d5 separated out grid functions for reuse inside gameState.lm
William Morgan <billjunk@mrgn.org>
parents: 45
diff changeset
146 }
d631e68a45d5 separated out grid functions for reuse inside gameState.lm
William Morgan <billjunk@mrgn.org>
parents: 45
diff changeset
147
45
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
148 }
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
149
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
150 nextTick <- :events {
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
151 print: 8
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
152 fold: events 0x7FFFFFFF with: :curMin event {
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
153 print: #[9 curMin event]
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
154 eventTick <- event value
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
155 print: 10
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
156 if: eventTick < curMin {
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
157 curMin <- eventTick
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
158 } else: {}
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
159 curMin
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
160 }
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
161 }
53
2c790eabe379 fixed bug with lambdaman/lambdaMan typo in gameState.
William Morgan <billjunk@mrgn.org>
parents: 52
diff changeset
162
45
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
163 print: 4
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
164 :runUntil {
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
165 tick <- 1
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
166 events <- [
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
167 endOfLives: 0
53
2c790eabe379 fixed bug with lambdaman/lambdaMan typo in gameState.
William Morgan <billjunk@mrgn.org>
parents: 52
diff changeset
168 moveLambdaman: 0
45
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
169 ]
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
170 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
171 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
172 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
173 events <- executeTick: tick events
53
2c790eabe379 fixed bug with lambdaman/lambdaMan typo in gameState.
William Morgan <billjunk@mrgn.org>
parents: 52
diff changeset
174 print: 7
2c790eabe379 fixed bug with lambdaman/lambdaMan typo in gameState.
William Morgan <billjunk@mrgn.org>
parents: 52
diff changeset
175 tick <- events nextTick
45
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
176 }
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
177 }
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
178 }
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
179
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
180 step <- :myState world {
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
181 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
182 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
183 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
184 })
57a4bddadd46 added new helper functions to grids. more bugfixes to gameState.lm which compiles.
William Morgan <billjunk@mrgn.org>
parents: 47
diff changeset
185
57a4bddadd46 added new helper functions to grids. more bugfixes to gameState.lm which compiles.
William Morgan <billjunk@mrgn.org>
parents: 47
diff changeset
186 ticker <- makeTicker: grid
45
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
187 print: 2
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
188 ticker: 1000
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
189 print: 3
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
190
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
191 #[0 0]
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
192 }
52
70423511f49d gameState now runs in gcc to completion without runtime errors.
William Morgan <billjunk@mrgn.org>
parents: 50
diff changeset
193 /*
45
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
194 main <- :initWorld ghostCode{
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
195 #[0 step]
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
196 }
52
70423511f49d gameState now runs in gcc to completion without runtime errors.
William Morgan <billjunk@mrgn.org>
parents: 50
diff changeset
197 */
70423511f49d gameState now runs in gcc to completion without runtime errors.
William Morgan <billjunk@mrgn.org>
parents: 50
diff changeset
198 main <- {
70423511f49d gameState now runs in gcc to completion without runtime errors.
William Morgan <billjunk@mrgn.org>
parents: 50
diff changeset
199 print: (step: 0 #[
70423511f49d gameState now runs in gcc to completion without runtime errors.
William Morgan <billjunk@mrgn.org>
parents: 50
diff changeset
200 //grid
70423511f49d gameState now runs in gcc to completion without runtime errors.
William Morgan <billjunk@mrgn.org>
parents: 50
diff changeset
201 [
70423511f49d gameState now runs in gcc to completion without runtime errors.
William Morgan <billjunk@mrgn.org>
parents: 50
diff changeset
202 [0 0 0 0]
70423511f49d gameState now runs in gcc to completion without runtime errors.
William Morgan <billjunk@mrgn.org>
parents: 50
diff changeset
203 [0 2 2 0]
70423511f49d gameState now runs in gcc to completion without runtime errors.
William Morgan <billjunk@mrgn.org>
parents: 50
diff changeset
204 [0 1 0 0]
70423511f49d gameState now runs in gcc to completion without runtime errors.
William Morgan <billjunk@mrgn.org>
parents: 50
diff changeset
205 [0 0 0 0]
70423511f49d gameState now runs in gcc to completion without runtime errors.
William Morgan <billjunk@mrgn.org>
parents: 50
diff changeset
206 ]
70423511f49d gameState now runs in gcc to completion without runtime errors.
William Morgan <billjunk@mrgn.org>
parents: 50
diff changeset
207 //lmstate
70423511f49d gameState now runs in gcc to completion without runtime errors.
William Morgan <billjunk@mrgn.org>
parents: 50
diff changeset
208 #[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
209 //ghost state
70423511f49d gameState now runs in gcc to completion without runtime errors.
William Morgan <billjunk@mrgn.org>
parents: 50
diff changeset
210 []
70423511f49d gameState now runs in gcc to completion without runtime errors.
William Morgan <billjunk@mrgn.org>
parents: 50
diff changeset
211 //fruit state
70423511f49d gameState now runs in gcc to completion without runtime errors.
William Morgan <billjunk@mrgn.org>
parents: 50
diff changeset
212 0
70423511f49d gameState now runs in gcc to completion without runtime errors.
William Morgan <billjunk@mrgn.org>
parents: 50
diff changeset
213 ])
70423511f49d gameState now runs in gcc to completion without runtime errors.
William Morgan <billjunk@mrgn.org>
parents: 50
diff changeset
214 }
45
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
215 }
75f808e60aa8 initial simulator ticker. needs print debug cleanup.
William Morgan <billjunk@mrgn.org>
parents:
diff changeset
216