gpt4 book ai didi

netlogo - 海龟从一个品种到另一个品种的发展

转载 作者:行者123 更新时间:2023-12-04 19:59:58 26 4
gpt4 key购买 nike

我对 netlogo 了解不多,所以这可能是一个非常简单的解决方案,但我有多种海龟品种,其中每个品种的年龄范围不同(鸡蛋、幼龟、幼龟、玳瑁(成人)),我需要它们能够去经过一定数量的滴答后从一个品种到下一个品种(在我的模型中,一个滴答=一天)。这可以编码吗?

到目前为止,这是我的代码

globals [island] 

Breed [eggs egg]
Breed [hatchlings hatchling]
Breed [juveniles juvenile]
Breed [hawksbills hawksbill]

turtles-own [
age
z
]

to setup
clear-all
set-default-shape eggs "circle"
create-eggs 80
[ set color 49.5
set size 0.5
setxy random-xcor random-ycor ]

set-default-shape hatchlings "turtle"
create-hatchlings 70
[ set color 57
set size 1.5
setxy random-xcor random-ycor ]

set-default-shape juveniles "turtle"
create-juveniles 10
[ set color 55
set size 2
setxy random-xcor random-ycor ]

set-default-shape hawksbills "turtle"
create-hawksbills 9
[ set color 53
set size 3
setxy random-xcor random-ycor ]

clear-output
setup-environment
setup-birthdays
reset-ticks

end

to setup-environment
ask patches [set pcolor cyan]
ask patches with [abs(pxcor) < 5 and abs(pycor) < 5] [set pcolor yellow]
ask patches with [abs(pxcor) < 2 and abs(pycor) < 2] [set pcolor brown]
end

to setup-birthdays

end

to go
ask eggs
[ kill-eggs ]
ask hatchlings
[ move-hatchlings
kill-hatchlings]
ask juveniles
[ move-juveniles
kill-juveniles]
ask hawksbills
[ move-hawksbills
kill-hawksbills
reproduce-hawksbills ]

tick
if not any? turtles [stop]
end

to kill-eggs
set z random 100
if z > 50
[die]
end

to kill-hatchlings
set z random 100
if z > 10
[die]
end

to kill-juveniles
set z random 20
if z > 18
[die]
end

to kill-hawksbills
set z random 5
if z > 4
[die]
end

to move-hatchlings
rt random 360
fd 1
end

to move-juveniles
rt random 360
fd 1
end

to move-hawksbills
rt random 360
fd 1
end

to reproduce-hawksbills
if pcolor = yellow
[set z random 100
if z > 75
[hatch-eggs 5[
set color 49.5
set size 0.5]
]]
end

最佳答案

要将乌龟变成幼龟,只需执行 set breed hatchlings !因此,您的代码可能类似于:

if age > 10 [
set breed hatchlings
]

关于netlogo - 海龟从一个品种到另一个品种的发展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29958027/

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