netlogo

NetLogo two agentsets operations

≡放荡痞女 提交于 2019-12-29 07:34:26
问题 I have two agentsets. Are there functions for finding: An agentset of agents that are present in both (intersection) An agentset of agents that are present in one and not the other I'm finding it very difficult to implement this by hand, especially when it's needed inside of a triple ask Ideal use would be similar to with syntax: let cross set1 and-in set2 let uniq set1 with [color = red] not-in set2 Simple things like "Is agent A in the agentset X?" are problematic 回答1: For the first one you

Adding patch clusters in a landscape

旧巷老猫 提交于 2019-12-29 01:47:09
问题 I would like to add forest patches in a landscape. To be more precise, the idea is to add patch clusters like "Patch Clusters" example. Contrary to this example, I want to randomly distribute some patch clusters with the same color and not several clusters that fill entirely the landscape. This is a beginning of code : to create-forests repeat 30 [ ask one-of patches [ set pcolor green ask neighbors [ set pcolor green] ] ] end With this code, the clusters look like squares and not clusters

Netlogo: Creating Hierarchical (tree) network with correct number of nodes

老子叫甜甜 提交于 2019-12-25 16:09:19
问题 I'm trying to create a 'Hierarchical' or 'Tree' network structure with a parameter expansion rate . At first, one node is placed at the top, and each node in the network is connected to a number of nodes below him equal to expansion rate . Currently my code looks like this: to wire-tree clear-all ask patches [ set pcolor white ] create-nodes 1 [ ; create root node of tree set shape "circle" set color red set branch 0 expand-network rewire-branches ] radial-layout reset-ticks end to expand

how to create a list of neighbors to verify if occupied or not by other turtles

不打扰是莪最后的温柔 提交于 2019-12-25 07:12:22
问题 i wont to know what neighbors are occupied from other turtles, in general terms i wont to know what patches are occupied in-radius from the turtles patch. Better if i can create a list of them or similar to verify what of this are occupied or no. Some suggestion? thanks 回答1: For the 8 neighboring patches: neighbors with [ any? turtles-here ] For patches in a radius: patches in-radius x with [ any? turtles-here ] 来源: https://stackoverflow.com/questions/24516240/how-to-create-a-list-of

NetLogo: avoid to have too many beetles on one patch in one time step?

六月ゝ 毕业季﹏ 提交于 2019-12-25 06:39:31
问题 I would like to implement certain rules into relationship between my turtles and my patches. My Patches variables are: n_min - if there is enough turtles, change pcolor to pink, change yellow turtles on patch to orange n_max - if there is too many turtles, set pcolor to brown, let all turtles to avoid this patch My turtles states are: yellow (move) -> orange (stay) -> red (infest) Patches states are: green (n_min< then number of orange turtles on one patch) pink (number of orange turtles is >

concatenate words in netlogo

荒凉一梦 提交于 2019-12-25 05:18:17
问题 NetLogo users I want to make a list which concatenates lists, for example Here is list 1 : [ 0 1 4 6 8] and here is list2 : (word "turtle") then I'd like to make list which ["turtle 0" "turtle 1" "turtle 4" turtle 8"] How could I possibily make this? Thank you in advance 回答1: Note that (word "turtle") is just "turtle", so I'm not quite sure what you want. But this should cover it. to-report append-word [w xs] report map [[x] -> (word w " " x)] xs end to-report append-words [ws xs] report map

calculating variance of a turtle-owned factor on a single patch in netlogo

一曲冷凌霜 提交于 2019-12-25 04:04:28
问题 I'm trying to calculate the variance of a turtle owned factor on a single patch. In other words at a single patch I'd like to know the mean and variance of the factor among all turtles on that patch. I know 'mean [FACTOR] of turtles-here' will give me the mean, but for some reason variance isn't working as well. Question 1: What is the proper syntax for asking a patch to output the variance of a turtle-owned factor? I've worked up a super simple example model. Just paste this in for your code

How to find a patch with a specific ID where there is a red turtle?

不打扰是莪最后的温柔 提交于 2019-12-25 03:59:09
问题 I have a problem with this code piece. ask persons [ set my-ID-polygon [ID-polygon] of patch-here [patch-here] of turtles with [color = red and shape = "x"] with [ID-polygon = my-ID-polygon] ] I obtain this error message: TURTLES breed does not own variable MY-ID-POLYGON In fact, I would like to have the patch with ID-polygon = my-ID-polygon where there is a turtle with color = red and shape = "x". Thanks in advance for your help. 回答1: I guess that my-ID-polygon is a persons variable, but in

How to setup a slider for pen size into the code in Netlogo

时光毁灭记忆、已成空白 提交于 2019-12-25 02:11:23
问题 this is my code , i need to fit the slider so i edit the pen size my global variable is turtle-pen-size to setup clear-all ask patches [ set pcolor sky ] setup-turtles end to setup-turtles create-turtles turtles-to-create [ set color lime setxy random-xcor random-ycor set size size-of-turtle] set-default-shape turtles "circle" end to go ask turtles[ ifelse pen-down? [ pen-down ] [ pen-up ] fd 1 ] end 回答1: You could set pen-size where you are asking each turtle to pen-down 回答2: I am not

Is there a way to create impassable barriers in NetLogo?

烈酒焚心 提交于 2019-12-25 01:58:00
问题 I am attempting to code a path-finding behavior wherein agents will locate an optimal patch in the environment and navigate their way around fences to reach said patch. I've created a patch variable 'f', which is set to 1 to indicate fences and 0 for any other patch. I want to make these fences impassable (i.e. I want them to be patches the agents will not use for movement), but agents still seem to be able to travel on them to some extent and in some cases are even able to fully cross them.