; It may be useful to keep windows around
(defvar *glut-window-opened* nil)
-(defvar *model* nil)
+(defvar *dimensions* nil)
(defvar *colors*
'((140 140 140) ; gray (5)
(gl:vertex 260 250 0)
(gl:end)))
-(defun initialize (model)
- "INITIALIZE MODEL => RESULT
+(defun initialize (&key dims)
+ "INITIALIZE &key DIMS => RESULT
+
+ DIMS: (:xmin XMIN :xmax XMAX :ymin YMIN :ymax YMAX)
ARGUMENTS AND VALUES:
- MODEL: A clnl-model:model to use to initialize the interface
RESULT: undefined
+ XMIN: An integer representing the minimum patch coord in X
+ XMAX: An integer representing the maximum patch coord in X
+ YMIN: An integer representing the minimum patch coord in Y
+ YMAX: An integer representing the maximum patch coord in Y
DESCRIPTION:
the interface lives. From here, one can go into headless or running
mode, but for certain things this interface will still need to act,
and also allows for bringing up and taking down of visual elements."
- (setf *model* model))
+ (setf *dimensions* dims))
(defun run ()
"RUN => RESULT
(sb-int:with-float-traps-masked (:invalid)
(cl-glut:init)
(cl-glut:init-window-size
- (floor
- (* *patch-size*
- (1+ (- (getf (clnl-model:world-dimensions *model*) :xmax) (getf (clnl-model:world-dimensions *model*) :xmin)))))
- (floor
- (* *patch-size*
- (1+ (- (getf (clnl-model:world-dimensions *model*) :ymax) (getf (clnl-model:world-dimensions *model*) :ymin))))))
+ (floor (* *patch-size* (1+ (- (getf *dimensions* :xmax) (getf *dimensions* :xmin)))))
+ (floor (* *patch-size* (1+ (- (getf *dimensions* :ymax) (getf *dimensions* :ymin))))))
(cl-glut:init-display-mode :double :rgba)
(cl-glut:create-window "CLNL Test Window")
(setf *glut-window-opened* t)
(render-buf (first (gl:gen-renderbuffers 1)))
;(width
; (floor (* *patch-size* (1+ (-
- ; (getf (clnl-model:world-dimensions *model*) :ymax)
- ; (getf (clnl-model:world-dimensions *model*) :ymin))))))
+ ; (getf *dimensions* :ymax)
+ ; (getf *dimensions* :ymin))))))
;(height
; (floor (* *patch-size* (1+ (- (getf *world-dims* :xmax) (getf *world-dims* :xmin))))))
; (floor (* *patch-size* (1+ (-
- ; (getf (clnl-model:world-dimensions *model*) :xmax)
- ; (getf (clnl-model:world-dimensions *model*) :xmin)))))
+ ; (getf *dimensions* :xmax)
+ ; (getf *dimensions* :xmin)))))
(width 143) ; Hard coded for now, yay v1 (if you see this comment in a year, please cry for me)
(height 143))
(gl:bind-framebuffer :framebuffer fbo)
is set so that multiple runs will evaluate to the same.
When FILE is not provided, a default model is used."
- (eval (model->lisp (if file (with-open-file (str file) (clnl-model:read-from-nlogo str)) (clnl-model:default-model)))))
+ (let
+ ((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)))
+ (eval netlogoed-lisp)))
(defun run-commands (cmds)
"RUN-COMMANDS CMDS => RESULT
(defun model->lisp (model)
`(progn
(clnl-random:set-seed 15) ; should the seed always be 15?
- (clnl-nvm:create-world ,model)
- (clnl-interface:initialize ,model)))
+ (clnl-nvm:create-world :dims ',(clnl-model:world-dimensions model))
+ (clnl-interface:initialize :dims ',(clnl-model:world-dimensions model))))
(defstruct ,type
,@(remove nil
(mapcar
- (lambda (def) (when (find (car def) (list :int :double :boolean :choice :string)) (second def)))
+ (lambda (def) (when (find (car def) (list :int :double :boolean :choice :string :option)) (second def)))
definitions)))
(push
(list
(:double `(coerce (read-from-string ,line) 'double-float))
(:boolean `(string= "1" ,line))
(:choice `(cadr (find ,line ',(third def) :key #'car :test #'string=)))
+ (:option `(when (string/= ,line ,(third def)) ,line))
(:string line))))
(when val-getter (list (intern (symbol-name (cadr def)) :keyword) val-getter))))
definitions
(:string tick-counter-label)
(:double frame-rate 30))
+(defwidget-definition slider
+ (:specified "SLIDER")
+ (:int left)
+ (:int top)
+ (:int right)
+ (:int bottom)
+ (:string display)
+ (:string varname)
+ (:string min)
+ (:string max)
+ (:double default)
+ (:string step)
+ (:reserved)
+ (:option units "NIL")
+ (:choice direction (("HORIZONTAL" :horizontal) ("VERTICAL" :vertical))))
+
(defun parse-interface (interface-as-strings)
(let
((widgets-as-strings
(defvar *turtles* nil)
(defvar *myself* nil)
(defvar *self* nil)
-(defvar *model* nil)
+(defvar *dimensions* nil)
(defvar *topology* :torus)
(defstruct turtle who color heading xcor ycor)
See http://ccl.northwestern.edu/netlogo/docs/dictionary.html#create-turtles"
(loop :for i :from 1 :to n :do (create-turtle)))
-(defun create-world (model)
- "CREATE-WORLD MODEL => RESULT
+(defun create-world (&key dims)
+ "CREATE-WORLD &key DIMS => RESULT
+
+ DIMS: (:xmin XMIN :xmax XMAX :ymin YMIN :ymax YMAX)
ARGUMENTS AND VALUES:
- MODEL: A clnl-model:model to use to initialize the vm
RESULT: undefined
+ XMIN: An integer representing the minimum patch coord in X
+ XMAX: An integer representing the maximum patch coord in X
+ YMIN: An integer representing the minimum patch coord in Y
+ YMAX: An integer representing the maximum patch coord in Y
DESCRIPTION:
This should be called before using the engine in any real capacity. If
called when an engine is already running, it may do somethign weird."
- (setf *model* model)
+ (setf *dimensions* dims)
(setf *turtles* nil)
(setf *current-id* 0))
(in-package #:clnl-nvm)
-(defun min-pxcor () (getf (clnl-model:world-dimensions *model*) :xmin))
-(defun max-pxcor () (getf (clnl-model:world-dimensions *model*) :xmax))
-(defun min-pycor () (getf (clnl-model:world-dimensions *model*) :ymin))
-(defun max-pycor () (getf (clnl-model:world-dimensions *model*) :ymax))
+(defun min-pxcor () (getf *dimensions* :xmin))
+(defun max-pxcor () (getf *dimensions* :xmax))
+(defun min-pycor () (getf *dimensions* :ymin))
+(defun max-pycor () (getf *dimensions* :ymax))