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