Main CLNL package
The entry point for general purpose clnl startup, as well as the place that ties all the parts together into a cohesive whole.
a package
The package named by :clnl-default-model-package
_model-package_ is used for interning symbols as a NetLogo code gets compiled.
:clnl-default-model-package is used because it's set up to shadow common overlaps between the :cl package and netlogo programs, most notably GO. When you set this to a package of your choosing, be aware of those overlaps in the case that use :use :common-lisp
Any local symbols are interned in this package, for use either by other code, or in order to have all symbols interned in the same placakge. This is also the package in which a model should be run, whether by clnl code or independently.
boot &optional file headless-mode => result
file---nlogo file with which to initialize state headless-mode---a boolean, defaults to nil result---undefined
boot does exactly that, boots the clnl system in a clean state. The seed is set so that multiple runs will evaluate to the same.
When file is not provided, a default model is used.
When headless-mode is set to nil, the opengl interface is initialized. Otherwise, the model will run headlessly, with no view.
model->multi-form-lisp model boot-fn &key seed initialize-interface netlogo-callback-fn => forms
model---A valid model boot-fn---A function name seed---An integer, defaults to 15 initialize-interface---A boolean netlogo-callback-fn---a symbol forms---A list of common lisp form
model->multi-form-lisp takes a model and returns a multi form lisp program, that when executed, sets up the model. Procedures map to defuns, globals to defvars, etc. This can be output to load up quickly later. A function named by boot-fn will be set for booting the program.
The seed passed in is used to start the clnl-random RNG.
initialize-interface, when non nil, leads to initialization code for the opengl interface being included.
netlogo-callback-fn is a symbol that will be defined as a function to be called to execute code in the running netlogo instance.
model->single-form-lisp model &key seed initialize-interface netlogo-callback => form
model---A valid model seed---An integer, defaults to 15 initialize-interface---A boolean netlogo-callback---A function of one argument, or a symbol form---A common lisp form
model->single-form-lisp takes a model and returns a lisp program as a single form, that when executed runs the model. The seed passed in is used to start the clnl-random RNG.
initialize-interface, when non nil, leads to initialization code for the opengl interface being included.
netlogo-callback is a function that when called with a single argument, a function that when called with netlogo code, will compile and run that code in the environment of the model.
Of note, all globals defined either in the model code or via the widgets are declared special in order to remain in the lexical environment for EVAL.
nlogo->lisp str pkg-symb boot-fn &key seed initialize-interface netlogo-callback-fn => forms
str---A stream holding an nlogo file pkg-symb---A symbol for the generated package boot-fn---A function name seed---An integer, defaults to 15 initialize-interface---A boolean netlogo-callback-fn---a symbol forms---A list of common lisp form
nlogo->lisp takes a stream str and returns a multi form lisp program, that when executed, sets up the model. See MODEL->MULTI-FORM-LISP for more information.
nlogo->lisp does extra work of setting up the package to be named by pkg-symb in order to correctly shadow common lisp functions.
It will also change the current package to the one created for the model named by pkg-symb.
(with-open-file (str "Wolf Sheep Predation.nlogo") (nlogo->lisp str :wolfsheep 'boot))
=> (forms)
run &optional file => result
file---nlogo file with which to initialize result---undefined, the system terminates at the end of the loop
run starts up the CLNL system.
run-commands cmds => result
cmds---A string that may have one more NetLogo commands result---undefined
run-commands will take NetLogo commands, put them through the various stages need to turn them into Common Lisp code, and run it.
run-reporter reporter => result
reporter---A string that should have only one reporter result---The value reported by the NVM
run-reporter will take a NetLogo reporter, put it through the various stages need to turn them into Common Lisp code, run it, and return the result.