1 (in-package #:clnl-nvm)
3 (defvar *current-id* 0)
9 (defvar *dimensions* nil)
10 (defvar *topology* :torus)
14 (define-condition stop nil nil)
16 (defmacro with-stop-handler (&rest forms)
17 "MACRO WITH-STOP-HANDLER &rest FORMS => HANDLED-FORM
21 FORMS: body to be handled
22 HANDLED-FORM: body with handling
26 WITH-STOP-HANDLER is a convenience macro to handle when
27 programs issue a stop condition. When one does, a simple
29 `(handler-case (progn ,@forms) (stop (s) :stop)))
31 (defstruct turtle who color heading xcor ycor (label "") (label-color 9.9d0) (size 1d0) shape)
32 (defstruct patch color xcor ycor)
34 (defun agentset-list (agentset)
36 ((eql agentset :turtles) *turtles*)
37 ((eql agentset :patches) *patches*)
38 ((and (listp agentset) (eql :agentset (car agentset))) (cddr agentset))
39 (t (error "Doesn't seem to be an agentset: ~A" agentset))))
41 (defun agentset-breed (agentset)
43 ((eql agentset :turtles) :turtles)
44 ((eql agentset :patches) :patches)
45 ((and (listp agentset) (eql :agentset (car agentset))) (second agentset))
46 (t (error "Doesn't seem to be an agentset: ~A" agentset))))
48 (defun list->agentset (list breed)
49 (append (list :agentset breed) list))
55 (and (listp o) (eql :agentset (car o)))))
58 (or (turtle-p o) (patch-p o)))
60 (defun breed-p (breed)
61 (find breed *breeds* :key #'car))
63 (defun breed-default-shape (breed)
64 (second (find breed *breeds* :key #'car)))
66 (defsetf breed-default-shape (breed) (shape)
67 `(setf (second (find ,breed *breeds* :key #'car)) ,shape))