gpt4 book ai didi

netlogo - 如何将我的代码从 Netlogo 转换为 Netlogo Web? ('TO or TO-REPORT expected' 错误)

转载 作者:行者123 更新时间:2023-12-02 01:22:20 27 4
gpt4 key购买 nike

我想使用 Netlogo Web 打开我的 Netlogo(桌面版)模型,但它似乎不起作用。当我尝试上传我的模型时,我收到一个“TO 或 TO-REPORT 预期”错误。不知道我做错了什么。我在下面插入了代码。它应该模拟一个细胞过程,其中细胞 split ,细胞细丝分支,细胞随着年龄的增长而改变形状(程序“ split ”、“分支”、“转化”)。请帮忙?

to setup
clear-all
setup-turtles
reset-ticks
ask turtles [ set size 1 ]
end

to setup-turtles
create-threads 1

ask turtles [
setxy random-xcor random-ycor
set shape "line"
set color 65
]
end

turtles-own [age]

to go
add-age
divide
branch
transform
tick
ask turtles [ set size 1 ]
end

breed [threads thread]
breed [cylinders cylinder]
breed [circles circle]


to add-age
ask turtles [
set age age + 1
ifelse show-age?
[ set label age ]
[ set label "" ]
]
end

to divide
ask turtles [
if breed = threads or breed = cylinders [
ifelse random 100 < 50
[if (not any? other turtles-on patch-ahead 1) and
(not any? other turtles-on patch-right-and-ahead 10 1) and
(not any? other turtles-on patch-left-and-ahead 10 1)
[hatch 1
[let turn-degree (random(20) - 10)
rt turn-degree
fd 1
set age age - 1
]
]
]
[if (not any? other turtles-on patch-right-and-ahead 180 1) and
(not any? other turtles-on patch-right-and-ahead 170 1) and
(not any? other turtles-on patch-right-and-ahead 190 1)
[hatch 1
[let turn-degree (170 + random(20))
rt turn-degree
fd 1
set age age - 1
]

]

]
]]
end

to branch
ask circles [
if random 1000 < 2[
ifelse random 100 < 50
[if not any? other turtles-on patch-right-and-ahead 90 1
[hatch-threads 1
[right 90
fd 1
set age 0
set shape "line"]
]
]
[if not any? other turtles-on patch-left-and-ahead 90 1
[hatch-threads 1
[left 90
fd 1
set age 0
set shape "line"]
]
]
]]
end

to transform
ask threads[
if (age > 50) and (random 100 < 50)[
set breed cylinders
set shape "cylinder1"
]
]
ask cylinders[
if (age > 100) and (random 100 < 50) [
set breed circles
set shape "circle"
]
]
end

最佳答案

NetLogo Web 对声明顺序更加严格(NetLogo Desktop 的 future 版本也是如此)。

只需移动您的turtles-ownbreed声明到你的代码顶部,你应该没事。

关于netlogo - 如何将我的代码从 Netlogo 转换为 Netlogo Web? ('TO or TO-REPORT expected' 错误),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39228797/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com