【发布时间】:2021-01-03 17:29:19
【问题描述】:
我只是在学习使用 netlogo,我正在尝试编写一个简单的模型来让不同的代理 [品种] 执行不同的任务。出现在界面/宇宙上的代理是用选择器选择的......
这是我在代码中写的:
breed [escarabajos escarabajo]; type of beetles that survive in forests
breed [beetles beetle]; type of beetles that survive in agricultural areas
;For each breed there are three sub-types of beetles, depending on how far they can move (vagility) this is also selected with a chooser.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; SETUP ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
to setup
ca
setup-patches
set-default-shape turtles "bug"
ask turtles [create-bichos]
reset-ticks
end
to setup-patches
ask n-of 100 patches [ set pcolor green ]
ask n-of 500 patches [set pcolor yellow]
end
to create-bichos
if breed = "escarabajo" [
ask patches with [ pcolor = green ] [
let k forest-carrying-capacity ; what I want is to create the maximum amount of beetles ;possible per patch, and this maximum is determined with a carrying capacity value, which is set ;with a slider....
sprout-escarabajos k [set color 116 set size 6]
]
]
if breed = "beetle" [
ask patches with [ pcolor = yellow ] [
let k agricultural-carrying-capacity
sprout-beetles k [set color 76 set size 6]
]
]
end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; GO ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
to go
if ticks = 72 [stop]
ask turtles [rt random 360
move
]
end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;; PROCEDURES ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
to move
if vagility = "High"
[ask turtles [
move-to one-of patches in-radius 2
]
]
if vagility = "medium"
[ask turtles [
move-to one-of neighbors
]
]
if vagility = "low"
[ask turtles [
move-to one-of neighbors4
]
]
end
就像我说的,代码似乎没有任何问题,但是当我点击设置按钮时,只出现不同颜色的补丁......
【问题讨论】: