5bac9b4b6e9972482fe9483a4833b47c9572fe76
[clnl] / src / main / clnl / nvm / world.lisp
1 (in-package #:clnl-nvm)
2
3 (defun clear-patches ()
4  (setf
5   *patches*
6   (loop
7    :for y :from (max-pycor) :downto (min-pycor)
8    :append (loop
9             :for x :from (min-pxcor) :to (max-pxcor)
10             :collect (make-patch
11                       :xcor (coerce x 'double-float)
12                       :ycor (coerce y 'double-float)
13                       :color 0d0)))))
14
15 (defun clear-turtles ()
16  (setf *turtles* nil)
17  (setf *current-id* 0))
18
19 (defun clear-ticks ()
20  (setf *ticks* nil))
21
22 (defcommand clear-all ()
23  "CLEAR-ALL => RESULT
24
25   RESULT: :undefined
26
27 DESCRIPTION:
28
29   Clears ticks, turtles, patches, globals (unimplemented).
30
31   See http://ccl.northwestern.edu/netlogo/docs/dictionary.html#clear-all"
32  (clear-turtles)
33  (clear-patches)
34  (clear-ticks))
35
36 (defcommand display ()
37  "DISPLAY => RESULT
38
39   RESULT: :undefined
40
41 DESCRIPTION:
42
43   As of yet, this does nothing.  A placeholder method for forced dipslay
44   updates from the engine.
45
46   See http://ccl.northwestern.edu/netlogo/docs/dictionary.html#display"
47  nil)
48
49 (defcommand reset-ticks ()
50  "RESET-TICKS => RESULT
51
52   RESULT: :undefined
53
54 DESCRIPTION:
55
56   Resets the tick counter to zero, sets up all plots, then updates all plots.
57
58   See http://ccl.northwestern.edu/netlogo/docs/dictionary.html#reset-ticks"
59  (setf *ticks* 0d0))
60
61 (defcommand tick ()
62  "RESET-TICKS => RESULT
63
64   RESULT: :undefined
65
66 DESCRIPTION:
67
68   Advances the tick counter by one and updates all plots.
69
70   If the tick counter has not been started yet with reset-ticks, an error results.
71
72   See http://ccl.northwestern.edu/netlogo/docs/dictionary.html#tick"
73
74  (when (not *ticks*) (error "reset-ticks must be called"))
75  (incf *ticks*))
76
77 (defun ticks ()
78  "TICKS => CURRENT-TICKS
79
80 ARGUMENTS AND VALUES:
81
82   CURRENT-TICKS: A positiv double, representing the current number of ticks
83
84 DESCRIPTION:
85
86   Reports the current value of the tick counter. The result is always a number and never negative.
87
88   If the tick counter has not been started yet with reset-ticks, an error results.
89
90   See http://ccl.northwestern.edu/netlogo/docs/dictionary.html#ticks"
91  (when (not *ticks*) (error "reset-ticks must be called"))
92  *ticks*)