我想将我的乌龟移动到其视野中最近的红色或绿色色块。我尝试了这段代码,但它没有移动。出了什么问题?
while [collectedDirt = 5]
[
ask turtle 0 [
let nearest-patch min-one-of (patches with [pcolor = red or pcolor = green] in-cone 15 20)[distancemyself]
face nearest-patch
fd distance nearest-patch
]
set collectedDirt collectedDirt + 1
search-dirt ;; research whether there is red patch in-cone because of new position
]