Using NetLogo with nashorn/js.
NetLogo is a multi-agent programmable modeling environment. See also http://ccl.northwestern.edu/netlogo/
Simple example demonstrating NetLogo controller API ( https://github.com/NetLogo/NetLogo/wiki/Controlling-API ) from Nashorn.
Copy scripts to your NetLogo installation directory and run it with "jjs" shell.