Netlogo:如何从某个起始点开始计算滴答声
我正在尝试建立一个病毒模拟器,我想让我的海龟在一定数量的蜱虫病后免疫。然而,我不知道如何计数蜱后,我已经感染了他们。我想让他们先病x蜱,然后再恢复健康(并且不能再被感染)。在我感染了蜱虫之后,有没有办法计算蜱虫的数量,或者我的问题有没有其他解决办法?你可以简单地为每只海龟保存感染的“日期”,例如设置感染日期蜱虫。 如果从感染开始的时间(Netlogo:如何从某个起始点开始计算滴答声,netlogo,Netlogo,我正在尝试建立一个病毒模拟器,我想让我的海龟在一定数量的蜱虫病后免疫。然而,我不知道如何计数蜱后,我已经感染了他们。我想让他们先病x蜱,然后再恢复健康(并且不能再被感染)。在我感染了蜱虫之后,有没有办法计算蜱虫的数量,或者我的问题有没有其他解决办法?你可以简单地为每只海龟保存感染的“日期”,例如设置感染日期蜱虫。 如果从感染开始的时间(ticks-infection date)大于x,则可以将变量immune?设置为true。为了避免免疫龟的感染,如果不免疫,只需使用?[…] 下面是一个简单的运
ticks-infection date
)大于x,则可以将变量immune?
设置为true。为了避免免疫龟的感染,如果不免疫,只需使用?[…]
下面是一个简单的运行示例。请注意,ticks-sick
没有注释,因为我在视图中使用了一个滑块来设置其值
turtles-own
[
infected?
infection-date
immune?
]
globals
[
; ticks-sick
]
to setup
ca
reset-ticks
crt 10
[
setxy random-xcor random-ycor
set infected? False
set immune? False
set infection-date "NA"
show-status
]
end
to go
tick
ask one-of turtles
[
get-infected
]
ask turtles
[
update-status
show-status
]
end
to get-infected
if not immune?
[
set infected? True
set infection-date ticks
]
end
to update-status
if not (infection-date = "NA")
[
if infected? and (ticks - infection-date) >= ticks-sick
[
set infected? False
set immune? True
]
]
end
to show-status
ifelse infected?
[ set color red]
[
ifelse immune?
[ set color blue]
[set color green]
]
end
您只需为每只海龟保存感染的“日期”,例如,set infection date ticks
。
如果从感染开始的时间(ticks-infection date
)大于x,则可以将变量immune?
设置为true。为了避免免疫龟的感染,如果不免疫,只需使用?[…]
下面是一个简单的运行示例。请注意,ticks-sick
没有注释,因为我在视图中使用了一个滑块来设置其值
turtles-own
[
infected?
infection-date
immune?
]
globals
[
; ticks-sick
]
to setup
ca
reset-ticks
crt 10
[
setxy random-xcor random-ycor
set infected? False
set immune? False
set infection-date "NA"
show-status
]
end
to go
tick
ask one-of turtles
[
get-infected
]
ask turtles
[
update-status
show-status
]
end
to get-infected
if not immune?
[
set infected? True
set infection-date ticks
]
end
to update-status
if not (infection-date = "NA")
[
if infected? and (ticks - infection-date) >= ticks-sick
[
set infected? False
set immune? True
]
]
end
to show-status
ifelse infected?
[ set color red]
[
ifelse immune?
[ set color blue]
[set color green]
]
end