diff 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
line wrap: on
line diff
--- a/src/lifter.tp	Sun Jul 15 21:56:43 2012 -0700
+++ b/src/lifter.tp	Sun Jul 15 23:55:29 2012 -0700
@@ -134,13 +134,43 @@
 			}
 			cullStatesTo <- :n {
 				print: "culling " . (states length) . " to " . n . "\n"
-				states <- topN: states n
+				if: n < (states length) {
+					states <- topN: states n
+				}
 				print: "states length is now " . (states length) . "\n"
 			}
 		}
 	}
 	
-	main <- {
+	main <- :args {
+		initmaxsteps <- 6
+		aftermaxsteps <- 5
+		cullstates <- 8
+		curarg <- 1
+		while: { curarg < (args length) } do: {
+			if: (args get: curarg) = "-is" {
+				curarg <- curarg + 1
+				if: curarg < (args length) {
+					initmaxsteps <- ((args get: curarg) int32)
+				}
+			} else: {
+				if: (args get: curarg) = "-as" {
+					curarg <- curarg + 1
+					if: curarg < (args length) {
+						aftermaxsteps <- ((args get: curarg) int32)
+					}
+				} else: {
+					if: (args get: curarg) = "-cs" {
+						curarg <- curarg + 1
+						if: curarg < (args length) {
+							cullstates <- ((args get: curarg) int32)
+						}
+					}
+				}
+			}
+			curarg <- curarg + 1
+		}
+		
 		text <- sim readFd: 0
 		initial <- (sim state) fromStr: text
 		os write: 2 text
@@ -148,7 +178,7 @@
 		os write: 2 "height: " . (string: (initial height)) . "\n"
 		
 		finder <- moveFinder: initial
-		initmaxsteps <- 6
+		
 		maxsteps <- initmaxsteps
 		while: { bestMove: finder withMaxSteps: maxsteps } do: {
 			best <- -1000000
@@ -163,8 +193,8 @@
 					bestscore <- s
 				}
 			}
-			finder cullStatesTo: 8
-			maxsteps <- initmaxsteps - 1
+			finder cullStatesTo: cullstates
+			maxsteps <- aftermaxsteps
 			os write: 2 "--------iteration results-------\n"
 			os write: 2 "Best:\n"
 			(finder curbest) printGrid
@@ -182,6 +212,6 @@
 		os write: 2 "---------------\n"
 		os write: 2 "End Best:\n"
 		(finder curbest) printGrid
-		
+		0
 	}
 }