不知道这到底意味着什么或是什么原因造成的。我的代码很大程度上是根据社区模型“Fire”建模的 错误:(第 36 行)这里需要一个数字,而不是一个列表或块。
globals [
initial-plants
triggered-plants
]
breed [signals signal]
to setup
clear-all
set-default-shape turtles "square"
ask patches with [(random-float 100) < density]
[ set pcolor green ]
ask patches with [pxcor = min-pxcor]
[ transmit ]
set initial-plants count patches with [pcolor = green]
set triggered-plants 0
ask patches with [ pcolor = red ] [
; See if there is any possible neighbor patch
; to whom I can spread my lack of concentration
let target one-of neighbors4 with [ pcolor = green ]
; if the target exists, have them change their color
if target != nobody [
ask target [
set pcolor red
]
]
]
reset-ticks
end
to go
if not any? turtles
[ stop ]
ask signal
[ask neighbors4 with [pcolor = green]
[ transmit ] ]
tick
end
to transmit
start signal 1
[ set color blue ]
set pcolor black
set triggered-plants triggered-plants + 1
end
我尝试寻找任何看起来不合适或有故障的东西,但我找不到。我的代码很短,所以应该不会那么难
您使用了单数“signal”,但需要使用复数“signals”。或者指定哪个信号。这就是您所描述的错误的来源。
此外,由于您使用了未定义的
start
,您收到了错误,但我认为这是您正在处理的其他事情?
这是您的代码的修订版本:
globals [
initial-plants
triggered-plants
]
breed [signals signal]
to setup
clear-all
set-default-shape turtles "square"
ask patches with [(random-float 100) < density]
[ set pcolor green ]
ask patches with [pxcor = min-pxcor]
[ transmit ]
set initial-plants count patches with [pcolor = green]
set triggered-plants 0
ask patches with [ pcolor = red ] [
; See if there is any possible neighbor patch
; to whom I can spread my lack of concentration
let target one-of neighbors4 with [ pcolor = green ]
; if the target exists, have them change their color
if target != nobody [
ask target [
set pcolor red
]
]
]
reset-ticks
end
to go
if not any? turtles
[ stop ]
ask signals
[ask neighbors4 with [pcolor = green]
[ transmit ] ]
tick
end
;to transmit
; start signal 1
; [ set color blue ]
; set pcolor black
; set triggered-plants triggered-plants + 1
;