You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+4-57Lines changed: 4 additions & 57 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,7 +27,7 @@ LevelSpace is an extension for NetLogo that allows you to run several models con
27
27
28
28
## LevelSpace fundamentals
29
29
30
-
LevelSpace must be loaded in a model using the ```extensions [ls]```command. Once this is done, a model will be able to load up other models using the LevelSpace primitives, run commands and reporters in them, and close them down when they are no longer needed.
30
+
LevelSpace must be loaded in a model using ```extensions [ls]```at the top of your model. Once this is done, a model will be able to load up other models using the LevelSpace primitives, run commands and reporters in them, and close them down when they are no longer needed.
31
31
32
32
Asking and reporting in LevelSpace is conceptually pretty straight forward: You pass blocks of code to child models, and the child models respond as if you had typed that string into their Command Center. LevelSpace allows you to report strings, numbers, and lists from a child to its parent. It is not possible to directly report turtles, patches, links, or any of their respective sets. Further, it is not possible to push data from a child to its parent - parents must ask their children to report.
33
33
@@ -107,18 +107,12 @@ let turtle-id 0
107
107
(ls:report model-id [ [ color ] of turtle ? ] turtle-id)
Like `ls:ask` and `ls:of`, but the list specifies a model at an arbitray place down the tree of models. This is useful when you child models that have child models that have child models and so forth.
117
-
118
-
For the hierarchical primitives, the list is read from left to right, and the reporter or command is passed down through the hierarchy. For instance, if we want to ask model 0's child model 1 to ask its child model 9 to call its `setup`, we would write
112
+
Reports a new list of models containing only those models that report true when they run the reporter block.
119
113
120
114
```
121
-
ls:ask-descendent [0 1 9] "setup"
115
+
ls:models ls:with [ count turtles > 100 ]
122
116
```
123
117
124
118
####`ls:let`_variable-name__data_
@@ -191,15 +185,6 @@ to go
191
185
end
192
186
```
193
187
194
-
### 'with' in LevelSpace.
195
-
The best way to do the equivalent of `with` in LevelSpace is to combine `filter` with `ls:of`. Let's for instance say that we only want the models that satisfy a set of particular criteria. For example:
196
-
197
-
```
198
-
ls:ask (filter [[ count turtles > 5 ] ls:of ?]) [
199
-
ask turtles [ fd 1 ]
200
-
]
201
-
```
202
-
203
188
### Caveats for `ls:let`
204
189
205
190
`ls:let` is very similar to `let`, except in a few cases.
@@ -253,44 +238,6 @@ ls:ask ls:models [
253
238
254
239
All models will print `1`.
255
240
256
-
#### You cannot access ls variables from inside tasks
257
-
258
-
This behavior should be considered a bug and not relied upon.
259
-
260
-
For example, this gives an error:
261
-
262
-
```
263
-
ls:let my-var 5
264
-
ls:ask model-id [
265
-
run task [
266
-
show my-var
267
-
]
268
-
]
269
-
```
270
-
271
-
The following won't error, but will give unexpected results:
272
-
273
-
```
274
-
ls:let my-var 5
275
-
ls:ask model-id [
276
-
(run task [ show foo + ? ] 7)
277
-
]
278
-
```
279
-
280
-
The child model will show 14 instead of 12.
281
-
282
-
Fortunately, there is an easy workaround in the case of `ls:ask`:
283
-
284
-
```
285
-
ls:let my-var 5
286
-
ls:ask model-id [
287
-
let var my-var
288
-
run task [
289
-
show var
290
-
]
291
-
]
292
-
```
293
-
294
241
#### `ls:let` does not respect the scope of `if`, `when`, and `repeat`
295
242
296
243
This behavior should be considered a bug and not relied upon. It is an unfortunate consequence of the way the NetLogo engine works. Hopefully, we'll be able to correct this in a future version of NetLogo.
0 commit comments