Mercurial > repos > icfp2012
diff src/lifter.tp @ 61:f851895ea67a
Add cullwhenover option and more tuning results
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 16 Jul 2012 02:20:38 -0700 |
parents | 7d4e51b4769a |
children | ff2b38518a58 |
line wrap: on
line diff
--- a/src/lifter.tp Mon Jul 16 01:55:04 2012 -0700 +++ b/src/lifter.tp Mon Jul 16 02:20:38 2012 -0700 @@ -103,6 +103,7 @@ visitedStates <- sets hash bestMove:withMaxSteps <- :self :max{ n <- 0 + hashelim <- 0 while: { if: (states length) > 0 { if: n < max { not: (curbest succeeded) } } } do: { nextstates <- #[] foreach: states :idx curstate { @@ -137,11 +138,11 @@ } } cullStatesTo <- :n { - print: "culling " . (states length) . " to " . n . "\n" + os write: 2 "culling " . (states length) . " to " . n . "\n" if: n < (states length) { states <- topN: states n } - print: "states length is now " . (states length) . "\n" + os write: 2 "states length is now " . (states length) . "\n" } } } @@ -151,6 +152,7 @@ aftermaxsteps <- 5 cullstates <- 8 curarg <- 1 + cullwhenover <- 0 while: { curarg < (args length) } do: { if: (args get: curarg) = "-is" { curarg <- curarg + 1 @@ -169,6 +171,13 @@ if: curarg < (args length) { cullstates <- ((args get: curarg) int32) } + } else: { + if: (args get: curarg) = "-co" { + curarg <- curarg + 1 + if: curarg < (args length) { + cullwhenover <- ((args get: curarg) int32) + } + } } } } @@ -185,27 +194,29 @@ maxsteps <- initmaxsteps while: { bestMove: finder withMaxSteps: maxsteps } do: { - best <- -1000000 - bestscore <- -1000000 - foreach: (finder states) :idx el { - h <- (el heuristic) - s <- (el score) - if: (h > best) { - best <- h - } - if: (s > bestscore) { - bestscore <- s - } + //best <- -1000000 + //bestscore <- -1000000 + //foreach: (finder states) :idx el { + // h <- (el heuristic) + // s <- (el score) + // if: (h > best) { + // best <- h + // } + // if: (s > bestscore) { + // bestscore <- s + // } + //} + if: ((finder states) length) > cullwhenover { + finder cullStatesTo: cullstates } - finder cullStatesTo: cullstates maxsteps <- aftermaxsteps os write: 2 "--------iteration results-------\n" os write: 2 "Best:\n" (finder curbest) printGrid - os write: 2 "Hash: " . ((finder curbest) hash) - os write: 2 "Current before cull\n" - os write: 2 " Best Heuristic: " . best . "\n" - os write: 2 " Best Score: " . bestscore . "\n" + //os write: 2 "Hash: " . ((finder curbest) hash) + //os write: 2 "Current before cull\n" + //os write: 2 " Best Heuristic: " . best . "\n" + //os write: 2 " Best Score: " . bestscore . "\n" //os write: 2 "After cull:\n" //foreach: (finder states) :idx el{ // os write: 2 " " . idx . " Heuristic: " . (el heuristic) . "\n"