5 The entry point for general purpose clnl startup, as well as the place that ties all the parts together into a cohesive whole.
9 * **variable [\*model\-package\*](#variable-model-package)** - _*model-package*_ is used for interning symbols as a NetLogo code gets compiled.
10 * **function [boot](#function-boot)** - _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.
11 * **function [model->multi-form-lisp](#function-model->multi-form-lisp)** - _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.
12 * **function [model->single-form-lisp](#function-model->single-form-lisp)** - _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.
13 * **function [nlogo->lisp](#function-nlogo->lisp)** - _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.
14 * **function [run](#function-run)** - _run_ starts up the CLNL system.
15 * **function [run-commands](#function-run-commands)** - _run-commands_ will take NetLogo commands, put them through the various stages need to turn them into Common Lisp code, and run it.
16 * **function [run-reporter](#function-run-reporter)** - _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_.
18 ## Variable \*MODEL\-PACKAGE\*
26 The package named by :clnl-default-model-package
30 _*model-package*_ is used for interning symbols as a NetLogo code gets compiled.
32 :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
34 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.
40 **boot** _&optional_ _file_ _headless-mode_ => _result_
42 #### Arguments and Values:
44 _file_---nlogo file with which to initialize state
45 _headless-mode_---a boolean, defaults to nil
50 _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.
52 When _file_ is not provided, a default model is used.
54 When _headless-mode_ is set to nil, the opengl interface is initialized. Otherwise, the model will run headlessly, with no view.
56 ## Function **MODEL->MULTI-FORM-LISP**
60 **model->multi-form-lisp** _model_ _boot-fn_ _&key_ _seed_ _initialize-interface_ _netlogo-callback-fn_ => _forms_
62 #### Arguments and Values:
64 _model_---A valid model
65 _boot-fn_---A function name
66 _seed_---An integer, defaults to 15
67 _initialize-interface_---A boolean
68 _netlogo-callback-fn_---a symbol
69 _forms_---A list of common lisp form
73 _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.
75 The _seed_ passed in is used to start the clnl-random RNG.
77 _initialize-interface_, when non nil, leads to initialization code for the opengl interface being included.
79 _netlogo-callback-fn_ is a symbol that will be defined as a function to be called to execute code in the running netlogo instance.
81 ## Function **MODEL->SINGLE-FORM-LISP**
85 **model->single-form-lisp** _model_ _&key_ _seed_ _initialize-interface_ _netlogo-callback_ => _form_
87 #### Arguments and Values:
89 _model_---A valid model
90 _seed_---An integer, defaults to 15
91 _initialize-interface_---A boolean
92 _netlogo-callback_---A function of one argument, or a symbol
93 _form_---A common lisp form
97 _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.
99 _initialize-interface_, when non nil, leads to initialization code for the opengl interface being included.
101 _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.
103 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.
105 ## Function **NLOGO->LISP**
109 **nlogo->lisp** _str_ _pkg-symb_ _boot-fn_ _&key_ _seed_ _initialize-interface_ _netlogo-callback-fn_ => _forms_
111 #### Arguments and Values:
113 _str_---A stream holding an nlogo file
114 _pkg-symb_---A symbol for the generated package
115 _boot-fn_---A function name
116 _seed_---An integer, defaults to 15
117 _initialize-interface_---A boolean
118 _netlogo-callback-fn_---a symbol
119 _forms_---A list of common lisp form
123 _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.
125 _nlogo->lisp_ does extra work of setting up the package to be named by _pkg-symb_ in order to correctly shadow common lisp functions.
127 It will also change the current package to the one created for the model named by _pkg-symb_.
131 ```(with-open-file (str "Wolf Sheep Predation.nlogo") (nlogo->lisp str :wolfsheep 'boot))``` => ```(forms)```
137 **run** _&optional_ _file_ => _result_
139 #### Arguments and Values:
141 _file_---nlogo file with which to initialize
142 _result_---undefined, the system terminates at the end of the loop
146 _run_ starts up the CLNL system.
148 ## Function **RUN-COMMANDS**
152 **run-commands** _cmds_ => _result_
154 #### Arguments and Values:
156 _cmds_---A string that may have one more NetLogo commands
161 _run-commands_ will take NetLogo commands, put them through the various stages need to turn them into Common Lisp code, and run it.
163 ## Function **RUN-REPORTER**
167 **run-reporter** _reporter_ => _result_
169 #### Arguments and Values:
171 _reporter_---A string that should have only one reporter
172 _result_---The value reported by the NVM
176 _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_.