X-Git-Url: https://code.consxy.com/gitweb/gitweb.cgi?a=blobdiff_plain;f=bin%2Fruncmd.scala;h=f4668874a455890a89105a628153573e28b19e85;hb=c739aec9e225747148c14c0c3b76f4147ff7be81;hp=f85ee7e61541d53b07cc5ba7ca82fd924903f9c5;hpb=daa3b99095a3219506e930c7dd684bfbab4cf107;p=clnl diff --git a/bin/runcmd.scala b/bin/runcmd.scala index f85ee7e..f466887 100755 --- a/bin/runcmd.scala +++ b/bin/runcmd.scala @@ -7,12 +7,12 @@ exec scalas "$0" -q "$@" logLevel in Global := Level.Error - scalaVersion := "2.10.3" + scalaVersion := "2.9.2" libraryDependencies ++= Seq( "asm" % "asm-all" % "3.3.1", "org.picocontainer" % "picocontainer" % "2.13.6", - "org.nlogo" % "NetLogoHeadless" % "6.0.0-M3" from "http://ccl.northwestern.edu/devel/6.0.0-M3/NetLogoHeadless.jar" + "org.nlogo" % "NetLogo" % "5.2.0" from "http://ccl.northwestern.edu/netlogo/5.2.0/NetLogo.jar" ) */ @@ -23,21 +23,63 @@ import org.nlogo.util.Utils.url2String import collection.JavaConversions._ +val input = io.Source.stdin.getLines.mkString("\n").split("\\@\\#\\$\\#\\@\\#\\$\\#\\@") + System.out.println("----") val workspace = HeadlessWorkspace.newInstance workspace.silent = true -workspace.openFromSource(url2String("file:resources/empty.nlogo")) -val input = io.Source.stdin.getLines.mkString("\n").split("\\@\\#\\$\\#\\@\\#\\$\\#\\@") -val commands = input(0) +if (input.length > 2 && input(2).length > 0) { + val modelSetup = input(2) + workspace.openFromSource(modelSetup + +""" +@#$#@#$#@ +GRAPHICS-WINDOW +210 +10 +649 +470 +-1 +-1 +13.0 +1 +10 +1 +1 +1 +0 +1 +1 +1 +-1 +1 +-1 +1 +0 +0 +1 +ticks +30.0 + +@#$#@#$#@ +@#$#@#$#@ +@#$#@#$#@ +NetLogo 5.2.0""") +} else { + workspace.openFromSource(url2String("file:resources/empty.nlogo")) +} workspace.mainRNG.setSeed(15) + +val commands = input(0) if(commands.length > 0) { - workspace.runCompiledCommands(new api.SimpleJobOwner("test", workspace.world.mainRNG, api.AgentKind.Observer), workspace.compileCommands(commands, api.AgentKind.Observer)) + workspace.runCompiledCommands(new api.SimpleJobOwner("test", workspace.world.mainRNG, classOf[api.Observer]), workspace.compileCommands(commands)) } -if(input.length > 0) { +if(input.length > 1) { val reporter = input(1) - System.out.println(org.nlogo.api.Dump.logoObject(workspace.runCompiledReporter(new api.SimpleJobOwner("test", workspace.world.mainRNG, api.AgentKind.Observer), workspace.compileReporter(reporter)))) + if(reporter.length > 0) { + System.out.println(org.nlogo.api.Dump.logoObject(workspace.runCompiledReporter(new api.SimpleJobOwner("test", workspace.world.mainRNG, classOf[api.Observer]), workspace.compileReporter(reporter)))) + } } workspace.world.exportWorld(new java.io.PrintWriter(System.out, true), true)