Je suis entrain de tester NetLogo, j'ai assemblé deux modèles Halo et Fire, ce que je voudrais faire, c'est lorsque le feu touche le halo d'une tortue, la tortue s'enfuit et prévient les autres tortues de ne pas aller dans la zone où se trouve le halo. Quand une tortue ne peut plus fuir (lorsque qu'elle est entourer de flamme) elle meurt, je ne vois pas comment faire ça.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62 breed [runners runner] breed [halos halo] globals [ initial-trees ] to setup clear-all set-default-shape halos "thin ring" create-runners 10 [ setxy random-xcor random-ycor ] ask runners [ set size 10 ] ask runners [ set color white ] ask patches [ if (random 100) < density [ set pcolor green ] if pxcor = min-pxcor [ set pcolor red ] ] set initial-trees count patches with [pcolor = green] reset-ticks end to go ask runners [ fd 0.5 ] walk if all? patches [ pcolor != red ] [ stop ] ask patches with [ pcolor = red ] [ ask neighbors with [ pcolor = green ] [ let probability probability-of-spread let direction towards myself if random 100 < probability [ set pcolor red ;if patches [pcolor = red] pxcor = xcor and patches [pcolor = red] pycor = ycor [die] ] ] set pcolor red - 3.5 ;if patches [pcolor = red-3.5] pxcor = xcor and patches [pcolor = red-3.5] pycor = ycor [die] ] tick end to make-halo hatch-halos 1 [ set size 15 set color yellow __set-line-thickness 1.5 create-link-from myself [ tie hide-link ] ] end to walk ask runners [ rt one-of [-90 0 90] forward 5 ] tick end
Éléments Graphique
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97 GRAPHICS-WINDOW 286 10 796 521 -1 -1 2.0 1 10 1 1 1 0 0 0 1 -125 125 -125 125 1 1 1 ticks 30.0 BUTTON 3 10 69 43 NIL setup NIL 1 T OBSERVER NIL NIL NIL NIL 1 BUTTON 4 50 71 83 NIL go T 1 T OBSERVER NIL NIL NIL NIL 0 SLIDER 7 137 189 170 density density 0.0 100.0 69.0 1.0 1 % HORIZONTAL MONITOR 122 25 220 70 percent burned ((count patches with [shade-of? pcolor red]) / initial-trees)\n* 100 1 1 11 SLIDER 6 182 188 215 probability-of-spread probability-of-spread 0 100 50.0 1 1 % HORIZONTAL
Partager