before_install:
- export DISPLAY=:99.0
- /sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1280x1024x24
- - wget http://frank.kank.net/travissbcl/clnl/213ed30/$(git rev-parse HEAD)/travissbcl
+ - wget http://frank.kank.net/travissbcl/clnl/72aabe5/$(git rev-parse HEAD)/travissbcl
- chmod +x travissbcl
script:
- ./travissbcl --script bin/all.lisp
tar zxf ../../deps/common-lisp/trivial-features_0.8.tar.gz &&
tar zxf ../../deps/common-lisp/cl-charms-9bb94ef.tar.gz &&
tar zxf ../../deps/common-lisp/style-checker_0.1.tar.gz &&
- tar zxf ../../deps/common-lisp/docgen_0.1.tar.gz &&
+ tar zxf ../../deps/common-lisp/docgen_0.2.tar.gz &&
tar zxf ../../deps/common-lisp/ieee-floats-92e481a.tar.gz &&
tar zxf ../../deps/common-lisp/strictmath_0.1.tar.gz
)
(in-package #:clnl)
+(defvar *model-package* (find-package :cl-user)
+ "*MODEL-PACKAGE*
+
+VALUE TYPE:
+
+ a package
+
+INITIAL VALUE:
+
+ The common-lisp-user package
+
+DESCRIPTION:
+
+ *MODEL-PACKAGE* is used for interning symbols as a NetLogo code
+ gets compiled.
+
+ 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.")
+
(defun e (ast) ast)
(defun r (str)
((netlogoed-lisp
(model->lisp
(if file (with-open-file (str file) (clnl-model:read-from-nlogo str)) (clnl-model:default-model))))
- (*package* (find-package :cl)))
+ (*package* *model-package*))
(eval netlogoed-lisp)))
(defun run-commands (cmds)
; The intention of this method is to generate the common lisp equivalent of a model file,
; such that if you decided to no longer use nlogo, you could use the engine without it.
(defun model->lisp (model)
- `(progn
+ `(let
+ ,(clnl-model:globals model)
(clnl-random:set-seed 15) ; should the seed always be 15?
(clnl-nvm:create-world :dims ',(clnl-model:world-dimensions model))
(clnl-interface:initialize :dims ',(clnl-model:world-dimensions model))))
:xmax (view-max-pxcor view)
:ymin (view-min-pycor view)
:ymax (view-max-pycor view))))
+
+(defun globals (model)
+ "GLOBALS MODEL => GLOBALS
+
+ GLOBALS: GLOBAL*
+
+ARGUMENTS AND VALUES:
+
+ MODEL: A valid model
+ GLOBAL: A symbol interned in clnl:*model-package*
+
+DESCRIPTION:
+
+ Returns the globals that get declared in the model, from widgets or
+ from code. They are interned in the package set for clnl, so
+ that they can later be used by functions in that package."
+ (mapcar
+ (lambda (pair)
+ (list
+ (intern (string-upcase (car pair)) clnl:*model-package*)
+ (cadr pair)))
+ (remove nil
+ (mapcar
+ (lambda (widget)
+ (typecase widget
+ (slider (list (slider-varname widget) (slider-default widget)))
+ (switch (list (switch-varname widget) (switch-on widget)))))
+ (model-interface model)))))
(defpackage #:clnl (:use :common-lisp)
- (:export #:run #:boot #:run-commands #:run-reporter)
+ (:export #:run #:boot #:run-commands #:run-reporter #:*model-package*)
(:documentation
"Main CLNL package
(defpackage #:clnl-model
(:use :common-lisp)
- (:export #:default-model #:read-from-nlogo #:world-dimensions)
+ (:export #:default-model #:read-from-nlogo #:world-dimensions #:globals)
(:documentation
"CLNL Model