Hello everyone,
I'm new at NetLogo; I have a few questions. I want to make
farms with different land sizes, and I want to differentiate each of them with
their colors, but I can't draw the borders of the farm; my yellow farms that
need to be next to each other are at other points, I tried to use radius but I
couldn't, can you help with the code?
Thank you very much.
Gizem
ask n-of 2 patches [set owner 1]
ask n-of 6 patches [set owner 2]
ask n-of 20 patches [set owner 3]
ask n-of 50 patches [set owner 5]
ask n-of 100 patches [set owner 6]
end
The original version had 2 major problems. One is that you always ask n random patches to change their owner without checking if they have already changed their owner before. This means that a patch can change owner multiple times which in turn means that the number of patches each farm has will generally be lower than the number you inputted (except for owner 6 since that is the last one).
The second problem is that there is nothing that ensures spatial clustering of the patches.
_______________________________
First version
to setup-owner-1
ask patches [set owner 0]
ask max-one-of patches with [owner = 0] [count neighbors with [owner = 0]] [ set owner 6]
repeat 99 [
ask one-of patches with [owner = 0 and any? neighbors4 with [owner = 6]] [set owner 6]
]
ask max-one-of patches with [owner = 0] [count neighbors with [owner = 0]] [ set owner 5]
repeat 49 [
ask one-of patches with [owner = 0 and any? neighbors4 with [owner = 5]] [set owner 5]
]
ask max-one-of patches with [owner = 0] [count neighbors with [owner = 0]] [ set owner 3]
repeat 19 [
ask one-of patches with [owner = 0 and any? neighbors4 with [owner = 3]] [set owner 3]
]
ask max-one-of patches with [owner = 0] [count neighbors with [owner = 0]] [ set owner 2]
repeat 5 [
ask one-of patches with [owner = 0 and any? neighbors4 with [owner = 2]] [set owner 2]
]
ask max-one-of patches with [owner = 0] [count neighbors with [owner = 0]] [ set owner 1]
repeat 1 [
ask one-of patches with [owner = 0 and any? neighbors4 with [owner = 1]] [set owner 1]
]
end
Hello Wannes,
firstly I Thank you for your answer, so I will try to explain my problem. I want to make five farms with different patch sizes, I create a 15*15 world, and my farm’s sizes are 2, 6, 20, 50, and 100. Total land patches are equal to 178. Finally, five farm owners are in the model. I want to see farm's own land patches adjacent. But my lands with different colors are scattered to World randomly; how do I get reunited patches to make farms? my codes are below,
best regards
Gizem
turtles-own [
land ]
patches-own [
owner ]
to setup
clear-all
setup-owner
reset-ticks
setup-people
update-variables
end
to setup-owner
ask n-of 2 patches [set owner 1]
ask n-of 6 patches [set owner 2]
ask n-of 20 patches [set owner 3]
ask n-of 50 patches [set owner 5]
ask n-of 100 patches [set owner 6]
end
to update-variables
check-display
end
to check-display
;; to update-Display and turtles colors
ask patches
[if _Display = "none" [set pcolor gray ]
if _Display = "owner"
[if owner = 0 [set pcolor white]
if owner = 1 [set pcolor orange + 4]
if owner = 2 [set pcolor yellow + 3]
if owner = 3 [set pcolor gray + 2]
if owner = 5 [set pcolor 109]
if owner = 6 [set pcolor green + 3] ]
]
ask turtles
[ ifelse _Turtle_color = "hide" [set hıdden? true] [set hıdden? false]
]
End
--
You received this message because you are subscribed to the Google Groups "netlogo-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netlogo-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netlogo-users/f3ac899c-5058-4614-80ea-40a546146d10n%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "netlogo-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netlogo-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netlogo-users/f66b9991-b5b2-4d43-b6dd-d88af6df7a9bn%40googlegroups.com.