1 (in-package #:cl-nl.nvm)
3 ; This is the engine. Yay.
5 (defvar *current-id* 0)
7 (defstruct turtle who color heading)
10 (defun create-turtle ()
12 (make-turtle :who *current-id*
13 :color (coerce (+ 5 (* 10 (cl-nl.random:next-int 14))) 'double-float)
14 :heading (coerce (cl-nl.random:next-int 360) 'double-float))
18 (defun create-turtles (n)
19 (loop for i from 1 to n do (create-turtle)))
21 (defun create-world ()
23 (setf *current-id* 0))
26 (multiple-value-bind (int rem) (floor n)
29 (format nil "~F" n))))
31 (defun export-world ()
32 (format nil "~{~A~%~}"
34 (format nil "~S" "RANDOM STATE")
35 (format nil "~S" (cl-nl.random:export))
37 (format nil "~S" "GLOBALS")
38 "\"min-pxcor\",\"max-pxcor\",\"min-pycor\",\"max-pycor\",\"perspective\",\"subject\",\"nextIndex\",\"directed-links\",\"ticks\","
39 (format nil "\"-1\",\"1\",\"-1\",\"1\",\"0\",\"nobody\",\"~A\",\"\"\"NEITHER\"\"\",\"-1\"" *current-id*)
41 (format nil "~S" "TURTLES")
42 "\"who\",\"color\",\"heading\",\"xcor\",\"ycor\",\"shape\",\"label\",\"label-color\",\"breed\",\"hidden?\",\"size\",\"pen-size\",\"pen-mode\""
43 (format nil "~{~A~%~}"
47 "\"~A\",\"~A\",\"~A\",\"0\",\"0\",\"\"\"default\"\"\",\"\"\"\"\"\",\"9.9\",\"{all-turtles}\",\"false\",\"1\",\"1\",\"\"\"up\"\"\""
49 (format-num (turtle-color turtle))
50 (format-num (turtle-heading turtle))))
52 (format nil "~S" "PATCHES")
53 "\"pxcor\",\"pycor\",\"pcolor\",\"plabel\",\"plabel-color\""
54 "\"-1\",\"1\",\"0\",\"\"\"\"\"\",\"9.9\""
55 "\"0\",\"1\",\"0\",\"\"\"\"\"\",\"9.9\""
56 "\"1\",\"1\",\"0\",\"\"\"\"\"\",\"9.9\""
57 "\"-1\",\"0\",\"0\",\"\"\"\"\"\",\"9.9\""
58 "\"0\",\"0\",\"0\",\"\"\"\"\"\",\"9.9\""
59 "\"1\",\"0\",\"0\",\"\"\"\"\"\",\"9.9\""
60 "\"-1\",\"-1\",\"0\",\"\"\"\"\"\",\"9.9\""
61 "\"0\",\"-1\",\"0\",\"\"\"\"\"\",\"9.9\""
62 "\"1\",\"-1\",\"0\",\"\"\"\"\"\",\"9.9\""
64 (format nil "~S" "LINKS")
65 "\"end1\",\"end2\",\"color\",\"label\",\"label-color\",\"hidden?\",\"breed\",\"thickness\",\"shape\",\"tie-mode\""