Program to quickly score two plants from the DB against each other
authorJoachim Breitner <mail@joachim-breitner.de>
Sun, 24 May 2009 19:26:50 +0000 (21:26 +0200)
committerJoachim Breitner <mail@joachim-breitner.de>
Sun, 24 May 2009 19:27:06 +0000 (21:27 +0200)
src/.gitignore
src/dbscorer.hs [new file with mode: 0644]

index 873a551..8e61dbd 100644 (file)
@@ -4,5 +4,6 @@
 main
 validate
 dbclient
+dbscorer
 fastScorer
 tags
diff --git a/src/dbscorer.hs b/src/dbscorer.hs
new file mode 100644 (file)
index 0000000..6bebace
--- /dev/null
@@ -0,0 +1,27 @@
+import Lseed.Data
+import Lseed.Data.Functions
+import Lseed.DB
+import Lseed.Grammar.Compile
+import Lseed.Grammar.Parse
+import Lseed.Mainloop
+import Control.Applicative
+import Control.Monad
+import Text.Printf
+
+getGarden = spread <$> map (either (error.show) compileGrammarFile . parseGrammar "" . dbcCode)
+                  <$> getCodeToRun
+  where spread gs = zipWith (\g p -> Planted ((fromIntegral p + 0.5) / l) p g (Stipe () 0 [])) gs [0..]
+         where l = fromIntegral (length gs)
+
+scoringObs = nullObserver {
+       obFinished = \garden -> do
+               forM_ garden $ \planted -> do
+                       printf "Plant from %d at %.4f: Total size %.4f\n"
+                               (plantOwner planted)
+                               (plantPosition planted)
+                               (plantLength (phenotype planted))
+       }
+
+main = do
+       garden <- getGarden
+       lseedMainLoop False scoringObs 10 garden