--- /dev/null
+(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.")
:maintainer "Frank Duncan (frank@kank.com)"
:author "Frank Duncan (frank@kank.com)"
:components ((:file "package")
+ (:file "base")
(:file "model")
(:file "lex")
(:file "parse")
(gl:translate x-modification y-modification 0)
(gl:rotate (getf turtle :heading) 0 0 -1)
(gl:scale *patch-size* *patch-size* 1)
+ (gl:scale (getf turtle :size) (getf turtle :size) 1)
(gl:call-list *turtle-list*)))
(list 0 (1- (world-width-in-pixels)) (- (1- (world-width-in-pixels))) 0 0)
(list 0 0 0 (1- (world-height-in-pixels)) (- (1- (world-height-in-pixels))))))
(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)
(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 ((agent turtle) (var (eql :who))) (turtle-who agent))
(defagent-value patch :pcolor patch-color)
+
+(defagent-value turtle :color)
+(defagent-value turtle :label)
+(defagent-value turtle :label-color)
+(defagent-value turtle :size)
(defvar *topology* :torus)
(defvar *ticks* nil)
-(defstruct turtle who color heading xcor ycor)
+(defstruct turtle who color heading xcor ycor (label "") (label-color 9.9d0) (size 1d0))
(defstruct patch color xcor ycor)
(defun agent-set-list (agent-set)
; Someday we'll have d<posint>, but this is not that day!
(cl-ppcre:regex-replace "d-" (cl-ppcre:regex-replace "d0" output "") "E-")))))
-(defmethod dump-object ((o string)) o)
+(defmethod dump-object ((o string)) (format nil "~A" (cl-ppcre:regex-replace-all "\"" (format nil "~S" o) "\"\"")))
(defmethod dump-object ((o (eql t))) "true")
(defmethod dump-object ((o (eql nil))) "false")
:color (turtle-color turtle)
:xcor (turtle-xcor turtle)
:ycor (turtle-ycor turtle)
- :heading (turtle-heading turtle)))
+ :heading (turtle-heading turtle)
+ :size (turtle-size turtle)))
*turtles*)
(mapcar
(lambda (patch)
(mapcar
(lambda (turtle)
(format nil
- "\"~A\",\"~A\",\"~A\",\"~A\",\"~A\",~A"
+ "\"~A\",\"~A\",\"~A\",\"~A\",\"~A\",\"\"\"default\"\"\",\"~A\",\"~A\",\"{all-turtles}\",\"false\",\"~A\",~A"
(dump-object (turtle-who turtle))
(dump-object (turtle-color turtle))
(dump-object (turtle-heading turtle))
(dump-object (turtle-xcor turtle))
(dump-object (turtle-ycor turtle))
- "\"\"\"default\"\"\",\"\"\"\"\"\",\"9.9\",\"{all-turtles}\",\"false\",\"1\",\"1\",\"\"\"up\"\"\""))
+ (dump-object (turtle-label turtle))
+ (dump-object (turtle-label-color turtle))
+ (dump-object (turtle-size turtle))
+ "\"1\",\"\"\"up\"\"\""))
*turtles*)))
(defun export-patches ()
(defsimpleprim :/ :reporter cl:/)
(defprim :any? :reporter (lambda (agentset) `(> (length ,agentset) 0)))
(defsimpleprim :ask :command clnl-nvm:ask)
+(defagentvalueprim :color)
(defsimpleprim :crt :command clnl-nvm:create-turtles)
(defsimpleprim :die :command clnl-nvm:die)
(defsimpleprim :fd :command clnl-nvm:forward)
,@(make-command-block-inline b))))
(defprim-alias :if-else :ifelse)
+(defagentvalueprim :label)
+(defagentvalueprim :label-color)
(defsimpleprim :lt :command clnl-nvm:turn-left)
(defkeywordprim :nobody)
(defsimpleprim :one-of :reporter clnl-nvm:one-of)
(defsimpleprim :rt :command clnl-nvm:turn-right)
(defsimpleprim :show :command clnl-nvm:show)
(defsimpleprim :set :command cl:setf)
+(defagentvalueprim :size)
(defsimpleprim :tick :command clnl-nvm:tick)
(defsimpleprim :ticks :reporter clnl-nvm:ticks)
(defsimpleprim :turtles :reporter clnl-nvm:turtles)
(defreportertestwithsetup "one-of 3" "crt 10" "one-of turtles" "(turtle 5)"
"A056ED8BF26A69FB4437E79F263E362C27F8820E")
+
+(defsimplecommandtest "color 1" "crt 10 ask turtles [ set color green ]"
+ "20943094E2C70D5A12AC6EEB29E8E9E2D21BD87D")
+
+(defsimplecommandtest "label 1" "crt 10 ask turtles [ set label who ]"
+ "96BF63544678A06E0D9A5062613CE1CAD638FCD5")
+
+(defsimplecommandtest "label-color 1" "crt 10 ask turtles [ set label-color green ]"
+ "70AB2BAA0BFD312256DDE6C02EE2B9C23E9B3532")
+
+(defsimplecommandtest "size 1" "crt 10 ask turtles [ set size 5 ]"
+ "8837CF2681A2091B0664FAA2C32062B19F548ED6")
(defviewtest "pcolor green" "ask patches [ set pcolor green ]"
"90F5F4870955B9FF02224F00E3C9814B8A6F766E")
+
+(defviewtest "size" "crt 10 ask turtles [ fd 2 set size 3 ] "
+ '("66E47E4579C2CA48CA672052B99F25DE94456D3A" "0A8EC908783A913CD15E9A0F19E6B8DBBA4EF5D9"))