error: "a patch cannot access a variable of a turtle without specifying which turtle" in NetLogo
error: "a patch cannot access a variable of a turtle without specifying which turtle" in NetLogo
我想阻止海龟访问它之前访问过的补丁。我正在开发代码,但出现此错误:error: "a patch cannot access a variable of a turtle without specifying which turtle".
我很确定这是另一个语法错误。但是,我找不到这个错误。我试图简化代码,让你们更容易帮助我。欢迎任何形式的帮助。
turtles-own: patchVisited
setup: set patchVisited (list patch-here)
go: set patchVisited lput patch-here patchVisited
move:
let availablePatch [neighbors with [not member? self [patchVisited] of myself and resource-value > 0.2 ]] of patch-here
let neighAvailable count availablePatch
move-to max-one-of availablePatch [resource-value]
改变
let availablePatch [ neighbors with [not member? self [patchVisited] of myself and resource-value > 0.2 ] ] of patch-here
至
let availablePatch neighbors with [not member? self [patchVisited] of myself and resource-value > 0.2 ]
你不需要neighbors of patch-here
,这就是neighbors
的意思。
总的来说: (1) NetLogo 高亮显示语法错误的行。这对我们(和您)来说是有用的信息,因此请将其包含在问题描述中。 (2) 对代码进行较小的更改——在继续之前让较小的更改生效。在这种情况下,您可以只让一只乌龟四处走动并执行类似以下操作:
ask neighbors with [not member? self [patchVisited] of myself] [set pcolor red]
之后又把补丁变白了。
我想阻止海龟访问它之前访问过的补丁。我正在开发代码,但出现此错误:error: "a patch cannot access a variable of a turtle without specifying which turtle".
我很确定这是另一个语法错误。但是,我找不到这个错误。我试图简化代码,让你们更容易帮助我。欢迎任何形式的帮助。
turtles-own: patchVisited
setup: set patchVisited (list patch-here)
go: set patchVisited lput patch-here patchVisited
move:
let availablePatch [neighbors with [not member? self [patchVisited] of myself and resource-value > 0.2 ]] of patch-here
let neighAvailable count availablePatch
move-to max-one-of availablePatch [resource-value]
改变
let availablePatch [ neighbors with [not member? self [patchVisited] of myself and resource-value > 0.2 ] ] of patch-here
至
let availablePatch neighbors with [not member? self [patchVisited] of myself and resource-value > 0.2 ]
你不需要neighbors of patch-here
,这就是neighbors
的意思。
总的来说: (1) NetLogo 高亮显示语法错误的行。这对我们(和您)来说是有用的信息,因此请将其包含在问题描述中。 (2) 对代码进行较小的更改——在继续之前让较小的更改生效。在这种情况下,您可以只让一只乌龟四处走动并执行类似以下操作:
ask neighbors with [not member? self [patchVisited] of myself] [set pcolor red]
之后又把补丁变白了。