我想在收集补丁的过程中创建一种反馈。在一个时间步,我想:
简单地说,补丁的收获总是会降低相邻补丁的成本,但是我连接的blob不能超过特定的大小(即补丁的数量)。
这是我迄今为止所做的 - 通过结合不同的收获技术(选择firt补丁,继续通过blob收获......)。但是,我确信有最简单的方法可以让它发挥作用吗?
globals [
limit_harvest ]
patches-own [
forest?
cost
]
to setup
clear-all
setup-patches
setup-turtles
reset-ticks
end
to setup-patches
ask patches [
set pcolor green
set forest? TRUE
set cost 20
]
end
to setup-turtles
crt 1
end
to go
if any? patches with [forest? = TRUE] [
harvest ]
if ticks mod 20 = 0 [
set limit_harvest 0 ]
tick
end
to harvest
ask turtles [
ifelse by_blob? = FALSE [
; let min_cost min-one-of patches []
move-to one-of patches with [
forest? = TRUE]
set pcolor red
set forest? FALSE
decrease_cost
]
[ print "continuous"
ifelse limit_harvest <= 10 [
let min_cost min-one-of patches with [forest? = TRUE ] [cost]
move-to min_cost
;min-one-of patches with [forest? = TRUE] [distance myself]
rt 360
set pcolor red
set forest? FALSE
decrease_cost
set limit_harvest limit_harvest + 1
]
[ move-else ]
]
]
end
to move-else
move-to one-of patches with [forest? = TRUE ]
set pcolor yellow
set forest? FALSE
decrease_cost
set limit_harvest limit_harvest + 1
harvest2
end
to harvest2
ifelse limit_harvest <= 10 [
let min_cost min-one-of patches with [forest? = TRUE ] [cost]
move-to min_cost
;min-one-of patches with [forest? = TRUE] [distance myself]
rt 360
set pcolor red
set forest? FALSE
decrease_cost
set limit_harvest limit_harvest + 1
]
[ move-else ]
end
to decrease_cost
ask patches in-radius 1 [
set cost (cost * 0.95 )]
ask patches in-radius 2 [
set cost (cost * 0.85 )]
ask patches in-radius 3 [
set cost (cost * 0.75 )]
ask patches in-radius 4 [
set cost (cost * 0.65 )]
end
to view_cost
ask patches [
set pcolor scale-color red cost 10 0
]
end