Systèmes Complexes : Une introduction par la pratique
Le site web du livre
Annexe A : Simulation orientée agent
Liens directs au sous-sections :
haut
A.6 Un exemple complet
globals [
nombre-agents
bulle-proximite
angle-vision
]
to setup
clear-all
set nombre-agents 50
create-turtles nombre-agents
ask turtles [
set xcor random 100
set ycor random 100
set heading random 360
set size 2
set color yellow
]
set bulle-proximite 2
set angle-vision 20
reset-ticks
end
to go
ask turtles [
ifelse (distance (min-one-of (other turtles) [distance myself]) >= bulle-proximite)
[ cheminer ]
[ fuire ]
]
tick
end
to cheminer
set heading (heading + random (angle-vision + 1) - (angle-vision / 2))
forward 1
end
to fuire
set heading (heading - 180)
forward 1
end
haut