X-Git-Url: https://code.consxy.com/gitweb/gitweb.cgi?p=clnl;a=blobdiff_plain;f=src%2Fmain%2Fnvm%2Fagent.lisp;h=8e97ea002c5bdf5ff4c06e12c8cd5a2b04ef9283;hp=ee1d97136ad72593b48c51fa2db6e1f47babbb04;hb=31f7cb6;hpb=97c390f3cee5094fa6795acd4b25b7598d5dd1bd diff --git a/src/main/nvm/agent.lisp b/src/main/nvm/agent.lisp index ee1d971..8e97ea0 100644 --- a/src/main/nvm/agent.lisp +++ b/src/main/nvm/agent.lisp @@ -54,3 +54,13 @@ DESCRIPTION: (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))))) + +(defmethod agent-value-inner ((patch patch) var) + (when (not (find var *patches-own-vars*)) (error "~S is not a patch variable" var)) + (or (getf (patch-own-vars patch) var) 0d0)) + +(defmethod set-agent-value-inner ((patch patch) var new-val) + (when (not (find var *patches-own-vars*)) (error "~S is not a patch variable" var)) + (if (getf (patch-own-vars patch) var) + (setf (getf (patch-own-vars patch) var) new-val) + (setf (patch-own-vars patch) (append (list var new-val) (patch-own-vars patch)))))