changeset 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 a37ceb0a4f5c
children b2ced94370a2
files Makefile src/lifter.tp tuning.sh tuningresults.txt
diffstat 4 files changed, 59 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Sun Jul 15 21:56:43 2012 -0700
+++ b/Makefile	Sun Jul 15 23:55:29 2012 -0700
@@ -16,7 +16,7 @@
 build/lifter.tp.c : src/sim.tp src/lifter.tp
 
 $(OUTDIR)/% : $(OBJDIR)/%.tp.c
-	gcc -ggdb -I$(TPDIR) -o $@ $< $(TPDIR)/runtime/object.c -lgc
+	gcc -O2 -I$(TPDIR) -o $@ $< $(TPDIR)/runtime/object.c -lgc
 
 $(OBJDIR)/%.tp.c : $(SRCDIR)/%.tp
 	$(TPC) -basedir $(TPDIR)/ -i src $(TPFLAGS) $< -o $@
--- 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
 	}
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tuning.sh	Sun Jul 15 23:55:29 2012 -0700
@@ -0,0 +1,12 @@
+#!/bin/sh
+echo $@ >> tuningresults.txt
+echo >> tuningresults.txt
+
+for file in maps/contest1.map maps/contest2.map maps/contest3.map maps/contest4.map maps/contest5.map maps/contest6.map maps/contest7.map maps/contest8.map; do
+	/usr/bin/time -f %E -o tuntiming.txt bin/lifter $@ < $file 2>tunout.txt
+	text=`tail -n 6 tunout.txt`
+	score=`echo $text | sed 's/.*score: \([0-9]*\).*/\1/'`
+	time=`cat tuntiming.txt`
+	echo "$file: $score ($time)";
+	echo "$file: $score ($time)" >> tuningresults.txt
+done
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tuningresults.txt	Sun Jul 15 23:55:29 2012 -0700
@@ -0,0 +1,10 @@
+-is 2 -as 1 -cs 500
+
+maps/contest1.map: 212 (0:01.22)
+maps/contest2.map: 275 (0:03.92)
+maps/contest3.map: 275 (0:05.03)
+maps/contest4.map: 575 (0:06.50)
+maps/contest5.map: 1295 (0:23.83)
+maps/contest6.map: 702 (1:19.81)
+maps/contest7.map: 869 (0:08.49)
+maps/contest8.map: 707 (6:22.09)