2 exec scalas "$0" -q "$@"
6 logLevel := Level.Error
8 logLevel in Global := Level.Error
10 scalaVersion := "2.9.2"
12 libraryDependencies ++= Seq(
13 "asm" % "asm-all" % "3.3.1",
14 "org.picocontainer" % "picocontainer" % "2.13.6",
15 "org.nlogo" % "NetLogo" % "5.2.0" from "http://ccl.northwestern.edu/netlogo/5.2.0/NetLogo.jar"
19 import org.nlogo.headless.HeadlessWorkspace
22 import org.nlogo.util.Utils.url2String
24 import collection.JavaConversions._
26 val input = io.Source.stdin.getLines.mkString("\n").split("\\@\\#\\$\\#\\@\\#\\$\\#\\@")
28 System.out.println("----")
29 val workspace = HeadlessWorkspace.newInstance
30 workspace.silent = true
32 if (input.length > 2 && input(2).length > 0) {
33 val modelSetup = input(2)
34 workspace.openFromSource(modelSetup +
69 Polygon -7500403 true true 150 5 40 250 150 205 260 250
74 Circle -1 true true 203 65 88
75 Circle -1 true true 70 65 162
76 Circle -1 true true 150 105 120
77 Polygon -7500403 true false 218 120 240 165 255 165 278 120
78 Circle -7500403 true false 214 72 67
79 Rectangle -1 true true 164 223 179 298
80 Polygon -1 true true 45 285 30 285 30 240 15 195 45 210
81 Circle -1 true true 3 83 150
82 Rectangle -1 true true 65 221 80 296
83 Polygon -1 true true 195 285 210 285 210 240 240 210 195 210
84 Polygon -7500403 true false 276 85 285 105 302 99 294 83
85 Polygon -7500403 true false 219 85 210 105 193 99 201 83
90 workspace.openFromSource(url2String("file:resources/empty.nlogo"))
93 workspace.mainRNG.setSeed(15)
95 val commands = input(0)
96 if(commands.length > 0) {
97 workspace.runCompiledCommands(new api.SimpleJobOwner("test", workspace.world.mainRNG, classOf[api.Observer]), workspace.compileCommands(commands))
99 if(input.length > 1) {
100 val reporter = input(1)
101 if(reporter.length > 0) {
102 System.out.println(org.nlogo.api.Dump.logoObject(workspace.runCompiledReporter(new api.SimpleJobOwner("test", workspace.world.mainRNG, classOf[api.Observer]), workspace.compileReporter(reporter))))
106 workspace.world.exportWorld(new java.io.PrintWriter(System.out, true), true)
107 System.out.println(org.nlogo.headless.Checksummer.calculateChecksum(workspace.world.exportWorld(_, true)))