X-Git-Url: https://code.consxy.com/gitweb/gitweb.cgi?p=clnl;a=blobdiff_plain;f=src%2Fmain%2Fnvm%2Fagent.lisp;h=ee1d97136ad72593b48c51fa2db6e1f47babbb04;hp=c52ca3a3dcb38f95d4ed56e14a27c309d9627781;hb=97c390f3cee5094fa6795acd4b25b7598d5dd1bd;hpb=f00d5c7c0e0b18f334da14c2e4107a7f1f68b45f diff --git a/src/main/nvm/agent.lisp b/src/main/nvm/agent.lisp index c52ca3a..ee1d971 100644 --- a/src/main/nvm/agent.lisp +++ b/src/main/nvm/agent.lisp @@ -35,6 +35,22 @@ DESCRIPTION: (defmethod agent-value-inner ((,agent ,type) (,var (eql ,symb))) (,accessor ,agent)) (defmethod set-agent-value-inner ((,agent ,type) (,var (eql ,symb)) ,new-val) (setf (,accessor ,agent) ,new-val))))) -(defagent-value turtle :who) +; Don't want the setter for :who +(defmethod agent-value-inner ((turtle turtle) (var (eql :who))) (turtle-who turtle)) (defagent-value patch :pcolor patch-color) + +(defagent-value turtle :color) +(defagent-value turtle :label) +(defagent-value turtle :label-color) +(defagent-value turtle :size) + +(defmethod agent-value-inner ((turtle turtle) var) + (when (not (find var *turtles-own-vars*)) (error "~S is not a turtle variable" var)) + (or (getf (turtle-own-vars turtle) var) 0d0)) + +(defmethod set-agent-value-inner ((turtle turtle) var new-val) + (when (not (find var *turtles-own-vars*)) (error "~S is not a turtle variable" var)) + (if (getf (turtle-own-vars turtle) var) + (setf (getf (turtle-own-vars turtle) var) new-val) + (setf (turtle-own-vars turtle) (append (list var new-val) (turtle-own-vars turtle)))))