I want with pressing the setup button at the netlogo tree and house shapes exist But only 3 person show to me Please help me:
breed [people person]
breed [houses house]
breed [trees tree]
to setup
clear-all
set-default-shape people "person"
set-default-shape houses "house"
set-default-shape trees "tree"
crt 3[
set color red
set size 2 ;; easier to see
setxy random-xcor random-ycor
]
Call create-houses (instead of crt) to create houses. See create-turtles in manual.
Related
I want a turtle to colour an area (in-radius 5), on top of the GIS data I have imported.
Please find attached the line of code I am using which is not working.
Is there any way how to do this?
Thanks!
extensions[gis]
globals [map-boundary]
to setup
ca
set map-boundary gis:load-dataset "/Users.shp"
create-turtles 50
ask turtles [setxy random-xcor random-ycor set size 1 set color grey]
gis:set-world-envelope (gis:envelope-union-of (gis:envelope-of map-boundary))
gis:import-wms-drawing "https://ows.terrestris.de/osm/service?" "EPSG:4326" "OSM-WMS" 1
reset-ticks
end
to go
ask turtle 1 [ask patches in-radius 5 [set pcolor blue]]
end
I'm not sure what you mean "not working", and lacking the datasets you have I can't reproduce the problem.
The Models Library has some GIS examples. What's not obvious is where Uri Walenski's "shared-dataset" files are that you need to run them models, but I found some version of them here:
https://ccl.northwestern.edu/netlogo/5.0/models/Code%20Examples/GIS/data/
and when I double-click countries.shp and countries.dbf they download and I can move them to my own new "shared-dataset" folder under the folder my model is in. That done, the model "create-turtles-inside-polygon" runs.
I removed most of and added a line to draw a blue region around turtle #1 and it seems to work. What does your attempt to draw the blue region do or not do that's different?
extensions [gis]
globals [dataset]
breed [citizens citizen]
citizens-own [cntry_name curr_type]
breed [manual-citizens manual-citizen]
manual-citizens-own [country-name currency-type]
to test-turtles
clear-all
set dataset gis:load-dataset "./shared-datasets/countries.shp"
gis:set-world-envelope gis:envelope-of dataset
gis:set-drawing-color red
gis:draw dataset 1
foreach gis:feature-list-of dataset [ country ->
gis:create-turtles-inside-polygon country turtles 1
;;clear-turtles
]
ask turtle 1 [ ask patches in-radius 5 [set pcolor blue]]
end
I have been following the tutorial listed here Netlogo tutorial pt3
In the section "Patches and variables" I simply do not observe the image shown when I followed the steps exactly.
Instead, I can only see a green cube with my agents seemingly stuck inside.
What am I missing here? My word is only a single cube.
These are the routines that I've copied from the tutorial that should show turtles scattered across the green patch.
to setup
clear-all
setup-patches
setup-turtles
reset-ticks
end
to setup-turtles
create-turtles 100
ask turtles [ setxy random-xcor random-ycor ]
end
to setup-patches
ask patches [ set pcolor green ]
end
It turns out the tutorial omits to tell you that you need to set the max-pzcor value in model settings to zero for this to work.
I'm looking to have a turtle-set form links with other turtle-set.
My current attempt that also feels contrived, as not every hive here will be selected.Is there another way of going about this?
to link-bees-to-hives [bees-agentset hives-agentset]
ask bees-agentset [
create-link-with one-of hives-agentset
]
end
How can I create links between two agentsets netlogo, in order of the turtles in the set?
Do you want to have bees make a link with just one other hive? If you have relatively enough bees your attempt is probably fine, but if you want to weight the bee selection so that they preferentially link with hives with fewer associate bees, you could use some kind of min-one-of solution or a perhaps something from the rnd extension. For example, a bee and hive setup:
extensions [ rnd ]
breed [ bees bee ]
breed [ hives hive ]
to setup
ca
create-hives 3 [
set color white
set shape "box"
set size 2
setxy random-xcor random-ycor
]
create-bees 15 [
set color yellow
set shape "bug"
setxy random-xcor random-ycor
]
reset-ticks
end
And the weighted selection:
to link-bee-to-hive
ask bees [
create-link-with rnd:weighted-one-of hives [ 1 - count my-links / count bees ]
]
print [ count my-links ] of hives
end
Of course, if you have few enough bees and hives, you may still end up with a hive or two not getting linked-to.
I am trying to move my agents from one vertex of my road network to another one which the following code. However, I got an error, saying that MOVE-TO expected input to be an agent but got NOBODY instead.
If new location is already defined which this code as part of the agentset of slocation, where is the problem?
to go
ask citizens [start-movement]
move
end
to start-movement
let nearest-node min-one-of nodes [distance myself]
set slocation nearest-node
move-to slocation
end
to move
ask citizens
[let new-location one-of [link-neighbors] of slocation
move-to new-location
set slocation new-location]
end
Here is a complete minimum working example copying your code and adding the setup and breed information required to make it run.
breed [ citizens citizen ]
citizens-own [slocation]
breed [ nodes node ]
to setup
clear-all
create-nodes 20 [ set color blue setxy random-xcor random-ycor ]
ask nodes [ create-links-with n-of 2 other nodes ]
create-citizens 1 [ set size 3 set color red ]
end
to go
ask citizens [start-movement]
move
end
to start-movement
let nearest-node min-one-of nodes [distance myself]
set slocation nearest-node
move-to slocation
end
to move
ask citizens
[ let new-location one-of [link-neighbors] of slocation
move-to new-location
set slocation new-location
]
end
This works fine. As I suggested in my comment, the most likely problem is that one of your citizens happened to start at a node without any link-neighbors. The way to check this is show count nodes with [not any? link-neighbors]. The error is saying that it couldn't find any agents in the set of link-neighbors.
If the nodes are only there to mark roads, then simply delete any that aren't marking roads. If there are other nodes as well, then you need to restrict your citizens to nodes that are road waypoints.
I have a breed worker, who has turtles-own variables pay and friend_pay, and I'd like to set a worker's friend_pay to be the highest pay from a near-by turtle. I tried the following, but it's not quite right. Can anyone please help?
ask workers [set friend_pay [pay] of [one-of workers in-radius 5 with-max [pay]] ]
The max-one-of primitive is your friend. It also doesn't complain if there are two equally paid friends. I think this does what you want.
breed [workers worker]
workers-own [pay friend-pay]
to setup
create-workers 50
[ setxy random-xcor random-ycor
set pay random 100
]
ask workers [ set friend-pay [pay] of max-one-of workers in-radius 5 [pay] ]
end