Mercurial > repos > icfp2012
comparison src/lifter.tp @ 67:ff8d7b4499f5 default tip
Submission prep
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 16 Jul 2012 04:48:50 -0700 |
parents | ff2b38518a58 |
children |
comparison
equal
deleted
inserted
replaced
66:cffcf36f1610 | 67:ff8d7b4499f5 |
---|---|
136 } else: { | 136 } else: { |
137 (states length) > 0 | 137 (states length) > 0 |
138 } | 138 } |
139 } | 139 } |
140 cullStatesTo <- :n { | 140 cullStatesTo <- :n { |
141 os write: 2 "culling " . (states length) . " to " . n . "\n" | |
142 if: n < (states length) { | 141 if: n < (states length) { |
143 states <- topN: states n | 142 states <- topN: states n |
144 } | 143 } |
145 os write: 2 "states length is now " . (states length) . "\n" | |
146 } | 144 } |
147 } | 145 } |
148 } | 146 } |
149 | 147 |
150 main <- :args { | 148 main <- :args { |
184 curarg <- curarg + 1 | 182 curarg <- curarg + 1 |
185 } | 183 } |
186 | 184 |
187 text <- sim readFd: 0 | 185 text <- sim readFd: 0 |
188 initial <- (sim state) fromStr: text | 186 initial <- (sim state) fromStr: text |
189 os write: 2 text | |
190 os write: 2 "width: " . (string: (initial width)) . "\n" | |
191 os write: 2 "height: " . (string: (initial height)) . "\n" | |
192 | 187 |
193 finder <- moveFinder: initial | 188 finder <- moveFinder: initial |
194 | 189 |
195 maxsteps <- initmaxsteps | 190 maxsteps <- initmaxsteps |
196 while: { bestMove: finder withMaxSteps: maxsteps } do: { | 191 while: { bestMove: finder withMaxSteps: maxsteps } do: { |
197 //best <- -1000000 | |
198 //bestscore <- -1000000 | |
199 //foreach: (finder states) :idx el { | |
200 // h <- (el heuristic) | |
201 // s <- (el score) | |
202 // if: (h > best) { | |
203 // best <- h | |
204 // } | |
205 // if: (s > bestscore) { | |
206 // bestscore <- s | |
207 // } | |
208 //} | |
209 if: ((finder states) length) > cullwhenover { | 192 if: ((finder states) length) > cullwhenover { |
210 finder cullStatesTo: cullstates | 193 finder cullStatesTo: cullstates |
211 } | 194 } |
212 maxsteps <- aftermaxsteps | 195 maxsteps <- aftermaxsteps |
213 os write: 2 "--------iteration results-------\n" | 196 } |
214 os write: 2 "Best:\n" | 197 (finder curbest) printMoves |
215 (finder curbest) printGrid | |
216 //os write: 2 "Hash: " . ((finder curbest) hash) | |
217 //os write: 2 "Current before cull\n" | |
218 //os write: 2 " Best Heuristic: " . best . "\n" | |
219 //os write: 2 " Best Score: " . bestscore . "\n" | |
220 //os write: 2 "After cull:\n" | |
221 //foreach: (finder states) :idx el{ | |
222 // os write: 2 " " . idx . " Heuristic: " . (el heuristic) . "\n" | |
223 // os write: 2 " " . idx . " Score: " . (el score) . "\n" | |
224 //} | |
225 //os write: 2 "Current:\n" | |
226 //(finder playfield) printGrid | |
227 } | |
228 os write: 2 "---------------\n" | |
229 os write: 2 "End Best:\n" | |
230 (finder curbest) printGrid | |
231 0 | 198 0 |
232 } | 199 } |
233 } | 200 } |