我正在尝试模拟蚊子和人类之间的感染,当为人类设置不同的状态时它有效但对于蚊子它不起作用
I am trying to model infection between mosquito and human, when setting different states for human it works but for mosquito it does not work
我正在尝试模拟蚊子和人类之间的感染,当为人类设置不同的状态时它有效但对于蚊子它不起作用。这是我用来设置蚊子感染的代码
ask one-of turtles [set infected? true]
if infected? [ set color blue]
完整代码为
breed [human humans]
breed [mosquito mosquitoes]
turtles-own
[
infected? ;; If true, the person is infected
recovered? ;; If true, the person has lived through an infection.
susceptible? ;; Tracks whether the person was initially susceptible
]
;;; SETUP PROCEDURES
to setup
clear-all
setup-human
setup-mosquito
reset-ticks
end
to setup-human
create-turtles 100
[
setxy random-xcor random-ycor
set recovered? false
set infected? false
set susceptible? true
set shape "person"
set color white
set size 1
ask one-of turtles[set infected? true]
if infected? [set color red]
]
end
to setup-mosquito
create-turtles 10
[
setxy random-xcor random-ycor
set susceptible? true
set infected? false
set shape "bug"
set color brown
set size 1
ask one-of turtles [set infected? true]
if infected? [ set color blue]
]
end
to go
ask turtles
[
set heading random 360
forward random 2
]
tick
end
您的代码中的括号不清楚,我看不到 if
语句中的内容。但是如果你的目标是在你感染蚊子的时候做几个动作,那么把它们放在一起就像:
ask one-of turtles
[ set infected? true
set color blue
]
我正在尝试模拟蚊子和人类之间的感染,当为人类设置不同的状态时它有效但对于蚊子它不起作用。这是我用来设置蚊子感染的代码
ask one-of turtles [set infected? true]
if infected? [ set color blue]
完整代码为
breed [human humans]
breed [mosquito mosquitoes]
turtles-own
[
infected? ;; If true, the person is infected
recovered? ;; If true, the person has lived through an infection.
susceptible? ;; Tracks whether the person was initially susceptible
]
;;; SETUP PROCEDURES
to setup
clear-all
setup-human
setup-mosquito
reset-ticks
end
to setup-human
create-turtles 100
[
setxy random-xcor random-ycor
set recovered? false
set infected? false
set susceptible? true
set shape "person"
set color white
set size 1
ask one-of turtles[set infected? true]
if infected? [set color red]
]
end
to setup-mosquito
create-turtles 10
[
setxy random-xcor random-ycor
set susceptible? true
set infected? false
set shape "bug"
set color brown
set size 1
ask one-of turtles [set infected? true]
if infected? [ set color blue]
]
end
to go
ask turtles
[
set heading random 360
forward random 2
]
tick
end
您的代码中的括号不清楚,我看不到 if
语句中的内容。但是如果你的目标是在你感染蚊子的时候做几个动作,那么把它们放在一起就像:
ask one-of turtles
[ set infected? true
set color blue
]