Mercurial > repos > icfp2012
comparison src/lifter.tp @ 57:397089dccb32
Compile with -O2. Add tuning parameters and tuning results script
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 15 Jul 2012 23:55:29 -0700 |
parents | fbeedb3aa239 |
children | 7d4e51b4769a |
comparison
equal
deleted
inserted
replaced
54:a37ceb0a4f5c | 57:397089dccb32 |
---|---|
132 (states length) > 0 | 132 (states length) > 0 |
133 } | 133 } |
134 } | 134 } |
135 cullStatesTo <- :n { | 135 cullStatesTo <- :n { |
136 print: "culling " . (states length) . " to " . n . "\n" | 136 print: "culling " . (states length) . " to " . n . "\n" |
137 states <- topN: states n | 137 if: n < (states length) { |
138 states <- topN: states n | |
139 } | |
138 print: "states length is now " . (states length) . "\n" | 140 print: "states length is now " . (states length) . "\n" |
139 } | 141 } |
140 } | 142 } |
141 } | 143 } |
142 | 144 |
143 main <- { | 145 main <- :args { |
146 initmaxsteps <- 6 | |
147 aftermaxsteps <- 5 | |
148 cullstates <- 8 | |
149 curarg <- 1 | |
150 while: { curarg < (args length) } do: { | |
151 if: (args get: curarg) = "-is" { | |
152 curarg <- curarg + 1 | |
153 if: curarg < (args length) { | |
154 initmaxsteps <- ((args get: curarg) int32) | |
155 } | |
156 } else: { | |
157 if: (args get: curarg) = "-as" { | |
158 curarg <- curarg + 1 | |
159 if: curarg < (args length) { | |
160 aftermaxsteps <- ((args get: curarg) int32) | |
161 } | |
162 } else: { | |
163 if: (args get: curarg) = "-cs" { | |
164 curarg <- curarg + 1 | |
165 if: curarg < (args length) { | |
166 cullstates <- ((args get: curarg) int32) | |
167 } | |
168 } | |
169 } | |
170 } | |
171 curarg <- curarg + 1 | |
172 } | |
173 | |
144 text <- sim readFd: 0 | 174 text <- sim readFd: 0 |
145 initial <- (sim state) fromStr: text | 175 initial <- (sim state) fromStr: text |
146 os write: 2 text | 176 os write: 2 text |
147 os write: 2 "width: " . (string: (initial width)) . "\n" | 177 os write: 2 "width: " . (string: (initial width)) . "\n" |
148 os write: 2 "height: " . (string: (initial height)) . "\n" | 178 os write: 2 "height: " . (string: (initial height)) . "\n" |
149 | 179 |
150 finder <- moveFinder: initial | 180 finder <- moveFinder: initial |
151 initmaxsteps <- 6 | 181 |
152 maxsteps <- initmaxsteps | 182 maxsteps <- initmaxsteps |
153 while: { bestMove: finder withMaxSteps: maxsteps } do: { | 183 while: { bestMove: finder withMaxSteps: maxsteps } do: { |
154 best <- -1000000 | 184 best <- -1000000 |
155 bestscore <- -1000000 | 185 bestscore <- -1000000 |
156 foreach: (finder states) :idx el { | 186 foreach: (finder states) :idx el { |
161 } | 191 } |
162 if: (s > bestscore) { | 192 if: (s > bestscore) { |
163 bestscore <- s | 193 bestscore <- s |
164 } | 194 } |
165 } | 195 } |
166 finder cullStatesTo: 8 | 196 finder cullStatesTo: cullstates |
167 maxsteps <- initmaxsteps - 1 | 197 maxsteps <- aftermaxsteps |
168 os write: 2 "--------iteration results-------\n" | 198 os write: 2 "--------iteration results-------\n" |
169 os write: 2 "Best:\n" | 199 os write: 2 "Best:\n" |
170 (finder curbest) printGrid | 200 (finder curbest) printGrid |
171 os write: 2 "Current before cull\n" | 201 os write: 2 "Current before cull\n" |
172 os write: 2 " Best Heuristic: " . best . "\n" | 202 os write: 2 " Best Heuristic: " . best . "\n" |
180 //(finder playfield) printGrid | 210 //(finder playfield) printGrid |
181 } | 211 } |
182 os write: 2 "---------------\n" | 212 os write: 2 "---------------\n" |
183 os write: 2 "End Best:\n" | 213 os write: 2 "End Best:\n" |
184 (finder curbest) printGrid | 214 (finder curbest) printGrid |
185 | 215 0 |
186 } | 216 } |
187 } | 217 } |