有没有办法在模拟过程中即使海龟死了也能产卵。在我的模拟中,鱼是吃浮游生物的,所以如果它们遇到浮游生物,浮游生物就会死亡/被吃掉。然而,当一条鱼不能再吃浮游生物时,它就会死亡,因为它不再通过吃浮游生物来获取能量。因此,当所有的鱼都死了,浮游生物应该会回来;由于迁徙等原因,浮游生物会大量生长。我不确定如何实现这一点?create函数在这里不起作用,只能在设置中起作用。
to plankton-reproduce
if random-float 100 < reproduce-plankton [
set energy (energy / 2)
hatch 1 [setxy random-xcor random-ycor]
]
if count plankton < 10 [
create-plankton 20
setxy random-xcor random-ycor
]错误:您不能在turtle上下文中使用create-plankton,因为create-plankton只是观察者
发布于 2015-12-04 00:14:30
我想我可能理解这个问题。
要让海龟创建海龟,请使用HATCH。你的代码可以工作(如果我理解的话)如果你使用
hatch-plankton 20而不是
create-plankton 20我做得对吗?海龟hatch,patches spawn和观察者creates。孵化出来的海龟将与孵化的海龟完全相同,并且都将在hatch被调用的地方。假设你不想那样做。使用
hatch-plankton 20 [setxy random-xcor random-ycor]发布于 2015-12-04 04:31:40
我已经在代码中加入了这一点,但当浮游生物数量为零时,就不会有浮游生物重新出生,这是因为所有的浮游生物都死了,不能孵化。你知道另一种方法可以在模拟过程中繁殖浮游生物或重新繁殖海龟,即使它们死了吗?在重现浮游生物的代码下面:
to plankton-reproduce
while [count plankton != 0 and count plankton < 3000]
[ if random-float 100 < reproduce-plankton
[set energy (energy / 2)
hatch-plankton 1 [setxy random-xcor random-ycor]]]
if count plankton = 0
[set energy 1
hatch-plankton 20 [setxy random-xcor random-ycor]]
endhttps://stackoverflow.com/questions/34069373
复制相似问题