( x . y )
email: frank@consxy.com | resume (pdf)

Package CLNL (link)

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.

Contents (link)

  • variable \model\-package\ - _model-package_ is used for interning symbols as a NetLogo code gets compiled.
  • 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.
  • 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.
  • 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.
  • 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.
  • function run - run starts up the CLNL system.
  • 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.
  • 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.

Variable \MODEL\-PACKAGE\ (link)

Value Type:

a package

Initial Value:

The package named by :clnl-default-model-package

Description:

_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.

Function BOOT (link)

Syntax:

boot &optional file headless-mode => result

Arguments and Values:

file---nlogo file with which to initialize state headless-mode---a boolean, defaults to nil result---undefined

Description:

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.

Function MODEL->MULTI-FORM-LISP (link)

Syntax:

model->multi-form-lisp model boot-fn &key seed initialize-interface netlogo-callback-fn => forms

Arguments and Values:

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

Description:

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.

Function MODEL->SINGLE-FORM-LISP (link)

Syntax:

model->single-form-lisp model &key seed initialize-interface netlogo-callback => form

Arguments and Values:

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

Description:

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.

Function NLOGO->LISP (link)

Syntax:

nlogo->lisp str pkg-symb boot-fn &key seed initialize-interface netlogo-callback-fn => forms

Arguments and Values:

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

Description:

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.

Examples:

(with-open-file (str "Wolf Sheep Predation.nlogo") (nlogo->lisp str :wolfsheep 'boot)) => (forms)

Function RUN (link)

Syntax:

run &optional file => result

Arguments and Values:

file---nlogo file with which to initialize result---undefined, the system terminates at the end of the loop

Description:

run starts up the CLNL system.

Function RUN-COMMANDS (link)

Syntax:

run-commands cmds => result

Arguments and Values:

cmds---A string that may have one more NetLogo commands result---undefined

Description:

run-commands will take NetLogo commands, put them through the various stages need to turn them into Common Lisp code, and run it.

Function RUN-REPORTER (link)

Syntax:

run-reporter reporter => result

Arguments and Values:

reporter---A string that should have only one reporter result---The value reported by the NVM

Description:

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.