Update documentation after 0.1.1 release
[clnl] / docs / DocsOtherPackages.md
1 # Package CLNL-INTERFACE
2
3 CLNL Interface
4
5 The NetLogo view interface using opengl.  This is responsible for taking the current state of the enging and displaying it.  Will not house any interface components.
6
7 ## Contents
8
9 * **function [export-view](#function-export-view)** - _export-view_ returns the current view in raw data of RGBA pixels.
10 * **function [initialize](#function-initialize)** - This is where the initialization of the interface that sits behind the interface lives.  From here, one can go into headless or running mode, but for certain things this interface will still need to act, and also allows for bringing up and taking down of visual elements.
11 * **function [run](#function-run)** - _run_ runs the view in an external window.
12
13 ## Function **EXPORT-VIEW**
14
15 #### Syntax:
16
17 **export-view** => _image-data_
18
19 #### Arguments and Values:
20
21 _image-data_---A vector, pixel data as returned by opengls readPixels  
22
23 #### Description:
24
25 _export-view_ returns the current view in raw data of RGBA pixels.
26
27 Each pixel is made up of 4 bytes of data, which an be walked over.  The number of pixels is the current width x height.  Converting to some other image format is a matter of pulling that information out and putting it into whatever format you like.
28
29 This requires opengl to run, but can be used with xvfb in a headless mode.
30
31 ## Function **INITIALIZE**
32
33 #### Syntax:
34
35 **initialize** _&key_ _dims_ _view_ _buttons_ _switches_ => _result_
36
37 ```dims::= (:xmin xmin :xmax xmax :ymin ymin :ymax ymax :patch-size patch-size)```  
38 ```view::= (:left left :top top)```  
39 ```buttons::= button-def*```  
40 ```switches::= switch-def*```  
41 ```button-def::= (:left left :top top :height height :width width :forever forever :display display)```  
42 ```switch-def::= (:left left :top top :width width :var var :display display :initial-value initial-value)```  
43
44 #### Arguments and Values:
45
46 _result_---undefined  
47 _xmin_---An integer representing the minimum patch coord in X  
48 _xmax_---An integer representing the maximum patch coord in X  
49 _ymin_---An integer representing the minimum patch coord in Y  
50 _ymax_---An integer representing the maximum patch coord in Y  
51 _patch-size_---A double representing the size of the patches in pixels  
52 _height_---An integer representing height  
53 _forever_---A boolean representing the forever status  
54 _left_---An integer representing the left position  
55 _top_---An integer representing the top position  
56 _width_---An integer representing width  
57 _var_---A string representing the variable name  
58 _display_---A string representing display name  
59 _initial-value_---The initial value  
60
61 #### Description:
62
63 This is where the initialization of the interface that sits behind the interface lives.  From here, one can go into headless or running mode, but for certain things this interface will still need to act, and also allows for bringing up and taking down of visual elements.
64
65 ## Function **RUN**
66
67 #### Syntax:
68
69 **run** => _result_
70
71 #### Arguments and Values:
72
73 _result_---undefined, should never get here  
74
75 #### Description:
76
77 _run_ runs the view in an external window.
78
79 This should be run inside another thread as it starts the glut main-loop. Closing this window will then cause the entire program to terminate.
80 # Package CLNL-LEXER
81
82 CLNL Lexer
83
84 The primary code responsible for tokenizing NetLogo code.
85
86 ## Contents
87
88 * **function [lex](#function-lex)** - _lex_ lexes NetLogo code.
89
90 ## Function **LEX**
91
92 #### Syntax:
93
94 **lex** _text_ => _ast_
95
96 #### Arguments and Values:
97
98 _text_---Some NetLogo code  
99 _ast_---An ambigious _ast_ that can later be parsed  
100
101 #### Description:
102
103 _lex_ lexes NetLogo code.
104
105 _lex_ checks for some things, in as much as it can without knowing anything about some of the backgrounds of NetLogo.  However, it does the first pass with as much as it can.
106 # Package CLNL-PARSER
107
108 CLNL Parser
109
110 All the code to convert the list of tokens coming from the lexer into an ast that can be transpiled later.
111
112 ## Contents
113
114 * **function [parse](#function-parse)** - _parse_ takes a ambigious _lexed-ast_ and converts it to an unambigious one.
115
116 ## Function **PARSE**
117
118 #### Syntax:
119
120 **parse** _lexed-ast_ _&optional_ _dynamic-prims_ => _ast_
121
122 ```dynamic-prims::= dynamic-prim*```  
123 ```dynamic-prim::= (:name name :args args :infix infix :precedence precedence)```  
124 ```args::= arg*```  
125
126 #### Arguments and Values:
127
128 _lexed-ast_---An ambigious ast  
129 _ast_---An unambigious ast that can be transpiled  
130 _name_---A symbol in the keyword package  
131 _infix_---Boolean denoting whether the prim is infix, defaulting to NIL  
132 _precedence_---A number, usually 10 for reporters, and 0 for commands  
133 _arg_---A list of symbols denoting the type of argument  
134
135 #### Description:
136
137 _parse_ takes a ambigious _lexed-ast_ and converts it to an unambigious one.
138
139 _dynamic-prims_ that are passed in are used to avoid compilation errors on things not statically defined by the NetLogo language, be they user defined procedures or generated primitives from breed declarations.  _name_ and _precedence_ are required for all dynamic prims.
140
141 _precedence_ is a number used to calculate the order of operations.  Higher numbers have more precedence than lower ones.  Generally all commands should have the lowest precedence, and all reporters should have 10 as the precedence.
142
143 The possible values for _arg_ are :agentset, :boolean, :number, :command-block, :string, or t for wildcard.  For optional arguments, _arg_ can be a list of the form (_arg_ :optional) where _arg_ is one of the aforementioned values.
144
145 The need for a parser between the lexer and the transpiler is because NetLogo needs two passes to turn into something that can be used.  This is the only entry point into this module, and should probably remain that way.
146
147 There's also a lot of error checking that the _lexed-ast_ even makes sense, even though the lexer obviously thought it did.
148
149 Examples are too numerous and varied, but by inserting an output between the lexer and this code, a good idea of what goes on can be gotten.
150 # Package CLNL-TRANSPILER
151
152 CLNL Transpiler
153
154 The transpiler is responsible for taking an ast and turning it into valid CL code targeting the nvm.  Here is where start to care about commands versus reporters and ensuring that things are in the right place.  The reason we wait until here is because we want to allow someone else to play with the AST before handing it off to us.  For instance, the command center wants to add "show" to reporters, and the users dictate based on entry point whether they are expecting a command or a reporter.  So monitors can say "hey, transpile this reporter" and we'll check to make sure it actually is.
155
156 Furthermore, the lisp code that any netlogo code would be transpiled to should use exported symbols, such that anyone writing NetLogo code in lisp could use the nvm in the same way that comes out of this transpiler All the code to convert the list of tokens coming from the lexer into an ast that can be transpiled later.
157
158 ## Contents
159
160 * **function [command-list-p](#function-command-list-p)** - _command-list-p_ returns whether the parsed-ast is a valid list of commands.
161 * **function [reporter-p](#function-reporter-p)** - _reporter-p_ returns whether the parsed-ast is a valid reporter.
162 * **function [transpile](#function-transpile)** - _transpile_ takes a unambigious _parsed-ast_ and converts it to Common Lisp code.  The _parsed-ast_ must be either a list of commands, or a single reporter.
163
164 ## Function **COMMAND-LIST-P**
165
166 #### Syntax:
167
168 **command-list-p** _parsed-ast_ => _result_
169
170 #### Arguments and Values:
171
172 _parsed-ast_---An ast as returned by the parser  
173 _result_---A boolean  
174
175 #### Description:
176
177 _command-list-p_ returns whether the parsed-ast is a valid list of commands.
178
179 ## Function **REPORTER-P**
180
181 #### Syntax:
182
183 **reporter-p** _parsed-ast_ => _result_
184
185 #### Arguments and Values:
186
187 _parsed-ast_---An ast as returned by the parser  
188 _result_---A boolean  
189
190 #### Description:
191
192 _reporter-p_ returns whether the parsed-ast is a valid reporter.
193
194 ## Function **TRANSPILE**
195
196 #### Syntax:
197
198 **transpile** _parsed-ast_ _&optional_ _dynamic-prims_ => _ast_
199
200 ```dynamic-prims::= dynamic-prim*```  
201 ```dynamic-prim::= (:name name :type type :macro macro :func func)```  
202 ```type::= :reporter | :command```  
203
204 #### Arguments and Values:
205
206 _parsed-ast_---An ast as returned by the parser  
207 _ast_---An common lisp _ast_ that can be actually run in a common lisp instance  
208 _name_---A symbol in the keyword package  
209 _macro_---A macro that will be called with the arguments ast  
210 _func_---A function that will be called with the transpiled arguments  
211
212 #### Description:
213
214 _transpile_ takes a unambigious _parsed-ast_ and converts it to Common Lisp code.  The _parsed-ast_ must be either a list of commands, or a single reporter.
215
216 When a set of _dynamic-prims_ is included, external language constructs can be also transpiled.  The provided functions will be inserted into the returned _ast_ with a call to _func_ALL.  If :macro is included, instead of having a call to _func_ALL provided, the macro will be run at netlogo transpile time, with the arguments it should have specified to the parser.  The result of that function call will then be dropped into the ast.
217
218 Calling eval on that code should work correctly as long as you have a running engine.
219 # Package CLNL-CODE-PARSER
220
221 CLNL Code Parser
222
223 A parser specifically for code from NetLogo models, that turns the lexed ast from an entire structured file into something more defined.
224
225 This is different from the general parser (in clnl-parser) in that it's made for parsing the code section of nlogo files, and so works outside of the constraints.  In NetLogo, I believe this is analagous to the StructureParser, but I'm guessing there's weird overlap with other things.
226
227 ## Contents
228
229 * **function [breeds](#function-breeds)** - Returns the breeds that get declared in the code.
230 * **function [globals](#function-globals)** - Returns the globals that get declared in the code.
231 * **function [parse](#function-parse)** - _parse_ takes a ambigious _lexed-ast_ and converts it to an unambigious one. It also returns the primitives that are defined in the code file, including ones generated from the _external-globals_, that can then be passed to both the parser and the transpiler.
232 * **function [patches-own-vars](#function-patches-own-vars)** - Returns the turtles own variables that get declared in the code.
233 * **function [procedures](#function-procedures)** - Returns the procedures that were defined in the code.  These can then be translated into common lisp by using mapcar on the _body_, and set to some function defined by _name_
234 * **function [turtles-own-vars](#function-turtles-own-vars)** - Returns the turtles own variables that get declared in the code.
235
236 ## Function **BREEDS**
237
238 #### Syntax:
239
240 **breeds** _code-parsed-ast_ => _breeds_
241
242 ```breeds::= breed*```  
243
244 #### Arguments and Values:
245
246 _code-parsed-ast_---An ast as created by clnl-code-parse:parse  
247 _breed_---A symbol interned in :keyword  
248
249 #### Description:
250
251 Returns the breeds that get declared in the code.
252
253 ## Function **GLOBALS**
254
255 #### Syntax:
256
257 **globals** _code-parsed-ast_ => _globals_
258
259 ```globals::= global*```  
260
261 #### Arguments and Values:
262
263 _code-parsed-ast_---An ast as created by clnl-code-parse:parse  
264 _global_---A symbol interned in :keyword  
265
266 #### Description:
267
268 Returns the globals that get declared in the code.
269
270 ## Function **PARSE**
271
272 #### Syntax:
273
274 **parse** _lexed-ast_ _&optional_ _external-globals_ => _ast_, _prims_
275
276 #### Arguments and Values:
277
278 _lexed-ast_---An ambigious ast  
279 _external-globals_---A list of symbols in keyword package  
280 _ast_---An unambigious ast that represents the code block of a model  
281 _prims_---Primitives that can be sent to the parser and transpiler  
282
283 #### Description:
284
285 _parse_ takes a ambigious _lexed-ast_ and converts it to an unambigious one. It also returns the primitives that are defined in the code file, including ones generated from the _external-globals_, that can then be passed to both the parser and the transpiler.
286
287 _external-globals_ is a list of symbols representing global variables that are not defined within the code.  Normally these come from widgets defined in the model file, but could arguably come from elsewhere.
288
289 This parser, unlike CLNL-_parse_:_parse_, should not be fed into the transpiler.
290
291 Rather, the ast that's returned can be queried with other functions included in the CLNL-CODE-_parse_R package to tease out necessary information.  Some of those things will involve code blocks that can then be transpiled.
292
293 ## Function **PATCHES-OWN-VARS**
294
295 #### Syntax:
296
297 **patches-own-vars** _code-parsed-ast_ => _patches-own-vars_
298
299 ```patches-own-vars::= patches-own-var*```  
300
301 #### Arguments and Values:
302
303 _code-parsed-ast_---An ast as created by clnl-code-parse:parse  
304 _patches-own-var_---A symbol interned in :keyword  
305
306 #### Description:
307
308 Returns the turtles own variables that get declared in the code.
309
310 ## Function **PROCEDURES**
311
312 #### Syntax:
313
314 **procedures** _code-parsed-ast_ => _procedures_
315
316 ```procedures::= procedure*```  
317 ```procedure::= (name body)```  
318
319 #### Arguments and Values:
320
321 _code-parsed-ast_---An ast as created by clnl-code-parse:parse  
322 _name_---A symbol interned in :keyword  
323 _body_---A list of lexed forms  
324
325 #### Description:
326
327 Returns the procedures that were defined in the code.  These can then be translated into common lisp by using mapcar on the _body_, and set to some function defined by _name_
328
329 ## Function **TURTLES-OWN-VARS**
330
331 #### Syntax:
332
333 **turtles-own-vars** _code-parsed-ast_ => _turtles-own-vars_
334
335 ```turtles-own-vars::= turtles-own-var*```  
336
337 #### Arguments and Values:
338
339 _code-parsed-ast_---An ast as created by clnl-code-parse:parse  
340 _turtles-own-var_---A symbol interned in :keyword  
341
342 #### Description:
343
344 Returns the turtles own variables that get declared in the code.
345 # Package CLNL-MODEL
346
347 CLNL Model
348
349 The representation, parsing, and serializing of NetLogo model files, including all of the sections, and subsections held within.  This package houses not only the code to read and write .nlogo files, but also the living state of the model as clnl runs.
350
351 ## Contents
352
353 * **function [buttons](#function-buttons)** - Returns button definitions that get declared in the buttons of the _model_.  This is used to initialize the interface.
354 * **function [code](#function-code)** - Returns the code from the model.
355 * **function [default-model](#function-default-model)** - Returns the default startup model.
356 * **function [execute-button](#function-execute-button)** - Executes the code in the button referenced by _name_ and _idx_.
357 * **function [forever-button-on](#function-forever-button-on)** - Returns whether the button identified by _name_ and _idx_ is currently on.
358 * **function [interface](#function-interface)** - _interface_ returns the widgets in _model_, used for display, or setting with SET-CURRENT-_interface_.
359 * **function [read-from-nlogo](#function-read-from-nlogo)** - Takes a stream _str_, reads in a nlogo file, parses it, and then returns the model object.
360 * **function [set-callback](#function-set-callback)** - Sets the means by which the interface can call arbitrary netlogo code.
361 * **function [set-current-interface](#function-set-current-interface)** - Sets the currently running model to _interface_.
362 * **function [sliders](#function-sliders)** - Returns slider definitions that get declared in the sliders of the _model_.  This is used to initialize the interface.
363 * **function [switches](#function-switches)** - Returns switch definitions that get declared in the switches of the _model_.  This is used to initialize the interface.
364 * **function [textboxes](#function-textboxes)** - Returns textbox definitions that get declared in the textboxes of the _model_.  This is used to initialize the interface.
365 * **function [view](#function-view)** - Returns the view definition that get declared in the view of the _model_.  This is used to initialize the interface.
366 * **function [widget-globals](#function-widget-globals)** - Returns the globals that get declared in the model from widgets. They are interned in the keyword package package set for clnl, so that they can later be used for multiple purposes.
367 * **function [world-dimensions](#function-world-dimensions)** - Returns the dimensions of _model_.  _model_ must be a valid model as parsed by CLNL, and have a valid view in it.
368
369 ## Function **BUTTONS**
370
371 #### Syntax:
372
373 **buttons** _model_ => _button-defs_
374
375 ```button-defs::= button-def*```  
376 ```button-def::= (:left left :top top :height height :width width :forever forever :display display)```  
377
378 #### Arguments and Values:
379
380 _model_---A valid model  
381 _left_---An integer representing the left position  
382 _top_---An integer representing the top position  
383 _height_---An integer representing height  
384 _width_---An integer representing width  
385 _forever_---A boolean representing whether this button is a forever button  
386 _display_---A string representing display name  
387
388 #### Description:
389
390 Returns button definitions that get declared in the buttons of the _model_.  This is used to initialize the interface.
391
392 ## Function **CODE**
393
394 #### Syntax:
395
396 **code** _model_ => _code_
397
398 #### Arguments and Values:
399
400 _model_---A valid model  
401 _code_---The string representing the netlogo code in this model  
402
403 #### Description:
404
405 Returns the code from the model.
406
407 ## Function **DEFAULT-MODEL**
408
409 #### Syntax:
410
411 **default-model** => _model_
412
413 #### Arguments and Values:
414
415 _model_---an object representing the model  
416
417 #### Description:
418
419 Returns the default startup model.
420
421 ## Function **EXECUTE-BUTTON**
422
423 #### Syntax:
424
425 **execute-button** _name_ _&optional_ _idx_ => _result_
426
427 #### Arguments and Values:
428
429 _name_---the name of the button  
430 _idx_---the instance of the button, defaults to 0  
431 _result_---undefined  
432
433 #### Description:
434
435 Executes the code in the button referenced by _name_ and _idx_.
436
437 _name_ refers to the display name for the button, which is usually set by the model, but sometimes defaults to the code inside.
438
439 Because _name_ is not guaranteed to be unique, _idx_ is available as a specifier.  The index is in the order that the buttons are loaded, and cannot be guaranteed to be stable from run to run.
440
441 ## Function **FOREVER-BUTTON-ON**
442
443 #### Syntax:
444
445 **forever-button-on** _name_ _&optional_ _idx_ => _on_
446
447 #### Arguments and Values:
448
449 _name_---the name of the button  
450 _idx_---the instance of the button, defaults to 0  
451 _on_---a boolean  
452
453 #### Description:
454
455 Returns whether the button identified by _name_ and _idx_ is currently on.
456
457 _name_ refers to the display name for the button, which is usually set by the model, but sometimes defaults to the code inside.
458
459 Because _name_ is not guaranteed to be unique, _idx_ is available as a specifier.  The index is in the order that the buttons are loaded, and cannot be guaranteed to be stable from run to run.
460
461 ## Function **INTERFACE**
462
463 #### Syntax:
464
465 **interface** _model_ => _interface_
466
467 #### Arguments and Values:
468
469 _model_---an object representing the model  
470 _interface_---a list of widgets for display  
471
472 #### Description:
473
474 _interface_ returns the widgets in _model_, used for display, or setting with SET-CURRENT-_interface_.
475
476 ## Function **READ-FROM-NLOGO**
477
478 #### Syntax:
479
480 **read-from-nlogo** _str_ => _model_
481
482 #### Arguments and Values:
483
484 _str_---a readable stream  
485 _model_---an object representing the model  
486
487 #### Description:
488
489 Takes a stream _str_, reads in a nlogo file, parses it, and then returns the model object.
490
491 ## Function **SET-CALLBACK**
492
493 #### Syntax:
494
495 **set-callback** _callback_ => _result_
496
497 #### Arguments and Values:
498
499 _callback_---a function that can take netlogo code  
500 _result_---undefined  
501
502 #### Description:
503
504 Sets the means by which the interface can call arbitrary netlogo code.
505
506 ## Function **SET-CURRENT-INTERFACE**
507
508 #### Syntax:
509
510 **set-current-interface** _interface_ => _result_
511
512 #### Arguments and Values:
513
514 _interface_---a list of widgets for display  
515 _result_---undefined  
516
517 #### Description:
518
519 Sets the currently running model to _interface_.
520
521 The widgets set here are comprised of the bare necessary to run the engine with or without an actual visual component.
522
523 ## Function **SLIDERS**
524
525 #### Syntax:
526
527 **sliders** _model_ => _slider-defs_
528
529 ```slider-defs::= slider-def*```  
530 ```slider-def::= (:left left :top top :width width :var var :display display :initial-value initial-value)```  
531
532 #### Arguments and Values:
533
534 _model_---A valid model  
535 _left_---An integer representing the left position  
536 _top_---An integer representing the top position  
537 _width_---An integer representing width  
538 _var_---A symbole representing variable  
539 _display_---A string representing variable name  
540 _initial-value_---The initial value  
541
542 #### Description:
543
544 Returns slider definitions that get declared in the sliders of the _model_.  This is used to initialize the interface.
545
546 ## Function **SWITCHES**
547
548 #### Syntax:
549
550 **switches** _model_ => _switch-defs_
551
552 ```switch-defs::= switch-def*```  
553 ```switch-def::= (:left left :top top :width width :var var :display display :initial-value initial-value)```  
554
555 #### Arguments and Values:
556
557 _model_---A valid model  
558 _left_---An integer representing the left position  
559 _top_---An integer representing the top position  
560 _width_---An integer representing width  
561 _var_---A symbole representing variable  
562 _display_---A string representing variable name  
563 _initial-value_---The initial value  
564
565 #### Description:
566
567 Returns switch definitions that get declared in the switches of the _model_.  This is used to initialize the interface.
568
569 ## Function **TEXTBOXES**
570
571 #### Syntax:
572
573 **textboxes** _model_ => _textbox-defs_
574
575 ```textbox-defs::= textbox-def*```  
576 ```textbox-def::= (:left left :top top :height height :width width :display display)```  
577
578 #### Arguments and Values:
579
580 _model_---A valid model  
581 _left_---An integer representing the left position  
582 _top_---An integer representing the top position  
583 _height_---An integer representing height, in characters  
584 _width_---An integer representing width, in characters  
585 _display_---A string representing display name  
586
587 #### Description:
588
589 Returns textbox definitions that get declared in the textboxes of the _model_.  This is used to initialize the interface.
590
591 ## Function **VIEW**
592
593 #### Syntax:
594
595 **view** _model_ => _view-def_
596
597 ```view-def::= (:left left :top top)```  
598
599 #### Arguments and Values:
600
601 _model_---A valid model  
602 _left_---An integer representing the left position  
603 _top_---An integer representing the top position  
604
605 #### Description:
606
607 Returns the view definition that get declared in the view of the _model_.  This is used to initialize the interface.
608
609 ## Function **WIDGET-GLOBALS**
610
611 #### Syntax:
612
613 **widget-globals** _model_ => _globals_
614
615 ```globals::= global*```  
616 ```global::= (name default)```  
617
618 #### Arguments and Values:
619
620 _model_---A valid model  
621 _name_---A symbol interned in the keyworkd package  
622 _default_---The widget default value  
623
624 #### Description:
625
626 Returns the globals that get declared in the model from widgets. They are interned in the keyword package package set for clnl, so that they can later be used for multiple purposes.
627
628 ## Function **WORLD-DIMENSIONS**
629
630 #### Syntax:
631
632 **world-dimensions** _model_ => _dims_
633
634 ```dims::= (:xmin xmin :xmax xmax :ymin ymin :ymax ymax)```  
635
636 #### Arguments and Values:
637
638 _model_---A valid model containing a view  
639 _xmin_---An integer representing the minimum patch coord in X  
640 _xmax_---An integer representing the maximum patch coord in X  
641 _ymin_---An integer representing the minimum patch coord in Y  
642 _ymax_---An integer representing the maximum patch coord in Y  
643
644 #### Description:
645
646 Returns the dimensions of _model_.  _model_ must be a valid model as parsed by CLNL, and have a valid view in it.
647 # Package CLNL-RANDOM
648
649 Wrapper around mt19937.
650
651 mt19937 implements a merseinne twister that must be adapted a little in order to match the implementation in the main NetLogo codebase which tries to match how java.util.Random works.  Turtles, all the way down.
652
653 ## Contents
654
655 * **function [export](#function-export)** - _export_ dumps out the random state to be export world ready.
656 * **function [next-double](#function-next-double)** - _next-double_ returns the next randomly generated double.
657 * **function [next-int](#function-next-int)** - _next-int_ returns the next randomly generated integer.
658 * **function [next-long](#function-next-long)** - _next-long_ returns the next randomly generated long.
659 * **function [set-seed](#function-set-seed)** - _set-seed_ sets the seed on the RNG.
660
661 ## Function **EXPORT**
662
663 #### Syntax:
664
665 **export** => _random-state_
666
667 #### Arguments and Values:
668
669 _random-state_---A dump of the current random state  
670
671 #### Description:
672
673 _export_ dumps out the random state to be export world ready.
674
675 When NetLogo dumps out the current state of the engine, the state of the RNG also gets dumped out so that it can be reinitialized later.  This accomplishes that.
676
677 This isn't really useful for regular use.
678
679 ## Function **NEXT-DOUBLE**
680
681 #### Syntax:
682
683 **next-double** _&optional_ _n_ => _double_
684
685 #### Arguments and Values:
686
687 _n_---A double representing the upper bound  
688 _double_---A double  
689
690 #### Description:
691
692 _next-double_ returns the next randomly generated double.
693
694 It does so in a way that's in accordance with java.util.Random and the MerseinneTwisterFast that's in _n_etLogo.  It also advances the R_n_G and is bounded by _n_.
695
696 ## Function **NEXT-INT**
697
698 #### Syntax:
699
700 **next-int** _n_ => _int_
701
702 #### Arguments and Values:
703
704 _n_---An integer representing the upper bound  
705 _int_---An integer  
706
707 #### Description:
708
709 _next-int_ returns the next randomly generated integer.
710
711 It does so in a way that's in accordance with java.util.Random and the MerseinneTwisterFast that's in _n_etLogo.  It also advances the R_n_G and is bounded by _n_.
712
713 ## Function **NEXT-LONG**
714
715 #### Syntax:
716
717 **next-long** _n_ => _long_
718
719 #### Arguments and Values:
720
721 _n_---A long representing the upper bound  
722 _long_---A long  
723
724 #### Description:
725
726 _next-long_ returns the next randomly generated long.
727
728 It does so in a way that's in accordance with java.util.Random and the MerseinneTwisterFast that's in _n_etLogo.  It also advances the R_n_G and is bounded by _n_.
729
730 ## Function **SET-SEED**
731
732 #### Syntax:
733
734 **set-seed** => _result_
735
736 #### Arguments and Values:
737
738 _result_---undefined  
739
740 #### Description:
741
742 _set-seed_ sets the seed on the RNG.