⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ---repro.nlogo

📁 NETLOGO
💻 NLOGO
字号:
;;there could be an advantage to having dependent offspring for communicating species
;;while they depend on the parent they can learn 

turtles-own [age
             fitness  
             knowhow]
             
breeds [talker silent]

globals [ p-mu max-fit min-fit]     ;; chances of mutating

;;all these vars are golbals for easy manipulation
;;globals [no-turtles        ;; number of turtles
;;         p-communicators   ;; the chance that a turtle will be a comunicator
;;         p-knowhow         ;; the chance that a turtle will have know-how
;;         no-things ]         ;; the numbr of different things to talk about
             
             
to setup
  ca             ;; clear the screen
  setup-globals
  set-default-shape talker "loud"
  set-default-shape silent "silent"
  setup-agents
  setup-plot
end

to setup-globals
set p-mu 0.05
end

to setup-agents
  crt no-turtles                                    ;; create given number of turtles
  ask turtles [set age random lifespan                    ;; set age to random number < lifespan
               setxy (random-int-or-float screen-size-x)  ;; randomize the turtle locations
                     (random-int-or-float screen-size-y)
               set fitness random (max-fit - (min-fit + 2 )) + (min-fit + 2) 
               init-vars]   
end

to init-vars
;; roll dice for breed
ifelse ((random 100) < (p-communicators * 100))  [ set breed talker ] [ set breed silent ]
;; roll dice for every knowledge-slot
set knowhow n-values no-things [round (((random 100) / 100) - (0.50 - p-knowhow))]
update-looks
end

to update-looks
Ifelse (no-things = 0) [set color 13] [set color (13 + ((reduce [?1 + ?2] knowhow) * 10))]
;; '(reduce [?1 + ?2] knowhow)' will output the number of nonzero items in knowhow
;; this sets the color proportional to the knowledge
set color scale-color color age 0 lifespan
end

to go
  ;; here all the steps are synchronised, i'm not shure that is neccesary
  ask turtles [offspring] 
  ask talker [communicate]
  ask turtles [update-looks]
  ask turtles [levi-flight]
  ask turtles [set age (age + 1)] 
  ask turtles [live-or-die]
  update-plot
end

to communicate
;;communicators tell all their neighbours, everything they know, at every step. This is not very realistic
;;find wich item is not zero and set that item to be non-zero with the neighbours
locals [own-knowhow]
set own-knowhow knowhow
ask turtles in-radius 1
         [ set knowhow map [max ?](map [list ?1 ?2] own-knowhow knowhow) ]
;; set the knowhow to a list with the max values from both the knowhows.
;; for some reason they also talk to themselfes, that is good
;; makes the counting of the number of interactions per turtle easier
end


to live-or-die
if age > lifespan [ die]
if fitness < min-fit [die]
end

to offspring
;;tweaking with the chances of having offspring makes the population unstable, they could all multipy or die out
;;the age at wich the turtles are fretile has no effect. But the longer the inteval the more unifrom the age distribution
;;dont really need the interval
if (( age >= (lifespan * (fretile - ( 0.5 * interval)))) and ( age <= (lifespan * (fretile + ( 0.5 * interval)))))
;;if the turtle is fretile
;;and other (ie luck, fitness) vars are ok
     [ if (random round (lifespan * interval)) = 1
            [hatch 1  [set age 0
                       set knowhow ( map [ tweak ? ] knowhow ) 
                       if ((random 100) < (p-mu * 100)) 
                             [ ifelse breed = talker [ set breed silent ] [set breed talker]] ]]]
;the knowledge and breed of the ofspring are tweaked a little to make it more realistic.
;NB maybe the knowledge should not be heridatory. The communicators should maybe just tell one thing at the 
;;time. And instead of being born with it the agents coud stumble on knowledge.
end

to-report tweak [l] ;;changes a value of 1 or 0 if (random number < P-mutation )
ifelse ((random 100) < (p-mu * 100)) [ ifelse l = 1 [ report 0] [report 1]] [ report l]           
end

;;;;;;;;;;;;;;;;THE PLOTTING PART;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


to setup-plot
  set-current-plot "agegroups"
  set-plot-x-range 0 (lifespan + 1)
  set-plot-y-range 0 round (no-turtles / lifespan) + 20
  set-histogram-num-bars lifespan
end

to update-plot
set-current-plot "agegroups"
histogram-from turtles [ age ]          ; using the default plot pen
;sum-list (values-from turtles [knowhow])  
end

to-report show-item-knowledge [list-count-items n]
if (list-count-items = []) [report ""]
report (word " .item" n ": " (first list-count-items) (show-item-knowledge (butfirst list-count-items) (n + 1)))
end

;;sum over lots of lists
to-report sum-list [lijst-van-lijsten]
if (lijst-van-lijsten = []) [report []]
report sum2 (first lijst-van-lijsten) (sum-list (but-first lijst-van-lijsten))
end
 
;;sum over 2 lists
to-report sum2 [list1 list2]
if (list2 = []) [report list1]
report (map [?1 + ?2] list1 list2)
end 
;;;;;;;;;;HOW TO MOVE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;; other ways to walk would be:
;; random
;; flocking
;; levi-flight / inverse levi-flight

;; om de invloed van beweging te meten:
;; kansen op communicatie
;; kansen op voedsel
;; zonder beweging - soms komt er een patch op met voedsel
;; kies random een beestje om mee te kletsen



to move-random
rt random-int-or-float 360
fd random 10
end

to levi-flight
 locals [ nummer ]
 rt random-int-or-float 360
 set nummer random 344
 if nummer = 0 
    [fd 15]
 if nummer = 1
    [fd 14]
 if nummer = 2
    [fd 13]
 if nummer = 3
    [fd 12]
 if nummer >= 4 and nummer < 6
    [fd 11]
 if nummer >= 6 and nummer < 8
    [fd 10]
 if nummer >= 8 and nummer < 11
    [fd 9]
 if nummer >= 11 and nummer < 15
    [fd 8]
 if nummer >= 15 and nummer < 19
    [fd 7]
 if nummer >= 19 and nummer < 25
    [fd 6]
 if nummer >= 25 and nummer < 33
    [fd 5] 
 if nummer >= 33 and nummer < 46
    [fd 4] 
 if nummer >= 46 and nummer < 69
    [fd 3]
 if nummer >= 69 and nummer < 122 
    [fd 2]
 if nummer >= 122 and nummer < 332
    [fd 1]
end







@#$#@#$#@
GRAPHICS-WINDOW
342
10
1956
845
200
100
4.0
1
14
1
1
1

CC-WINDOW
396
410
814
570
Command Center

BUTTON
201
10
256
43
setup
setup
NIL
1
T
OBSERVER
T

BUTTON
275
10
330
43
NIL
go
T
1
T
OBSERVER
T

SLIDER
8
55
162
88
no-turtles
no-turtles
0
600
200
5
1
NIL

SLIDER
8
10
180
43
p-communicators
p-communicators
0
1
0.1
0.1
1
NIL

PLOT
21
442
330
562
agegroups
age
#tur.
0.0
100.0
0.0
100.0
true
true
PENS
"default" 1.0 1 -16777216 true

SLIDER
7
99
123
132
fretile
fretile
0
1
0.5
0.1
1
NIL

SLIDER
9
147
181
180
lifespan
lifespan
0
70
25
1
1
NIL

SLIDER
13
198
128
231
interval
interval
0
1
1.0
0.1
1
NIL

SLIDER
167
54
339
87
p-knowhow
p-knowhow
0
1
0.1
0.1
1
NIL

SLIDER
161
98
333
131
no-things
no-things
0
10
10
1
1
NIL

MONITOR
2
351
763
400
turtles knowing item
show-item-knowledge (sum-list (values-from turtles [knowhow]) ) 1
0
1

MONITOR
38
251
102
300
#turtles
count turtles
3
1

@#$#@#$#@
WHAT IS IT?
-----------
We would like the turtles to make groups and to share knowledge within that group. The way to do this would be to pick a way of moving around that ensures groupforming. 

The other 2 reasons to have the agents move aroud are:
*walking around ensures that the chances of stumbling on food or on a talking agent are random. This could be done by just randomly adjusting knowledge and foodaccesibility.
*it looks cool

The moving around should not influence the advantages of communicating and if it does we should know about it.

The purpose of this particular model is to evaluate the influence of the moving-around algorithm on the communication- and feeding possibilities of the agents. The main idea is that the properties of every model should be characterised with a simple array of values. This is done with the converging values from the "tmp monitor" plot.


HOW IT WORKS
------------
It has all the same things as the other models, only it focuses on making the properties of the different walks visible. There are 3 plots:

1) communicators 
This is the plot that shows the influense of the walk on the communication.
> %com (red) - shows the current % of agents that communicate. For every agent the breed is decided on at birth with the chance of being a 'talker' (ie an agent that communicates) is p-communicator (=user defined). But the actual % of talkers will fluctuate. 
> av %talk (blue) - at every step the talkers talk to their neighbours. The number of times a turtle will have been talked to depends on its age. That is why this is the average per timestep: mean (values-from turtles [ (talked / age) * 100 ]))
> dev talk (ligh blue) - This is the standard deviation of above var. the number of encounters per turtle will depend on the density of turtles and the way they move. I want to know if some models make big differences between individual turtles

2) steps
This plot shows the ground covered. As long as the chances of finding food (or something alse nice) on a patch are random, it does not metter much how much ground the turtles cover. But if the chances of finding food depend on how long ago a turtle was at that patch than it might matter.
> av steps (pink) - average number of steps, in a model without pressure all turtles live to be 23, but if the pressure goes up, the av age may fall. Than the chances of getting a lot of knowledge (and communicating it) will fall too. 
> av %new (brown)- shows % of steps that put turtles on patches they have'nt been before (mean (values-from turtles [ (been / age) * 100 ]))

3) tmp monitor
Monitors the mean-over-time so the values converge to one
These values should give a measure of the influence of the walk and turtle density.
> talked (blue) - average percantage of steps a turtle gets talked to
> talked-per%com (red) - percantage of steps a turtle gets talked to, devided by talker-silent ratio 
> newsteps (brown) - % of steps that put turtles on patches they have'nt been before
> dev-talked (ligh blue) - st dev of 'talked'
> talked-perden (green) - (number of times talked to) / (age * density)


HOW TO USE IT
-------------
p-communicators - chances a newborn turtle will communicate
no-turtles - number of turtles

these vars are not important for now:
p-kowhow - the chances a turtle will know somethig
no-things - the number of different things a turtle can know

THINGS TO NOTICE
----------------
For some reason the standard deviation of (talked/age) is in a big interval: 3-27.
For a density of 0.05 it fluctuates less 5-25
For levi-flight it is less.


THINGS TO TRY
-------------
Turn off the turtle-screen. That way netlogo can get on with plotting.


EXTENDING THE MODEL
-------------------
Model
The way the algorithm actually works out could depend on other things. For example if only turtles that know something have a chance of surviving than it becomes very important to be near others to share information. Now the turtles have a short, fixed life-span. But if they were allowed to live longer than turtles that allready knew stuff could wander away from the group.

Interface
*there should be a way to choose the way of walking
*choose screensize



RELATED MODELS
--------------
talk


CREDITS AND REFERENCES
----------------------
@#$#@#$#@
default
true
0
Polygon -7566196 true true 150 5 40 250 150 205 260 250

circle
false
0
Circle -7566196 true true 35 35 230

loud
false
15
Circle -1 true true 4 9 285
Rectangle -16777216 true false 118 46 179 246
Rectangle -1 true true 105 24 189 51
Rectangle -1 true true 105 31 196 56
Rectangle -1 true true 99 33 189 60
Rectangle -1 true true 108 193 205 205
Rectangle -1 true true 96 193 197 210
Rectangle -1 true true 174 38 201 267
Rectangle -1 true true 109 34 123 258
Rectangle -1 true true 102 26 125 246
Rectangle -1 true true 171 44 191 254
Rectangle -16777216 true false 125 36 170 80
Rectangle -16777216 true false 125 243 170 268
Rectangle -1 true true 104 195 193 218
Rectangle -1 true true 172 15 172 21
Rectangle -1 true true 169 29 192 276
Rectangle -1 true true 90 197 187 223
Rectangle -16777216 true false 125 219 168 229
Rectangle -16777216 true false 157 219 168 232
Rectangle -16777216 true false 158 219 169 241
Rectangle -16777216 true false 124 214 168 224
Rectangle -16777216 true false 160 214 171 215
Rectangle -16777216 true false 158 215 171 224
Rectangle -1 true true 168 195 188 227
Rectangle -16777216 true false 164 214 168 239
Rectangle -16777216 true false 164 216 172 228
Rectangle -16777216 true false 165 209 171 223
Rectangle -1 true true 169 202 185 241
Rectangle -1 true true 149 198 185 213
Rectangle -1 true true 159 203 175 213
Rectangle -1 true true 160 204 175 213
Rectangle -1 true true 159 207 176 214
Rectangle -1 true true 109 205 124 228
Rectangle -1 true true 116 200 124 229
Rectangle -1 true true 111 206 125 230

silent
false
15
Polygon -1 true true 69 6 4 64 200 278 275 210
Polygon -1 true true 79 276 17 216 203 7 276 67

slnt
true
15
Circle -1 true true 2 48 79
Circle -1 true true 53 11 104
Circle -1 true true 131 15 119
Circle -1 true true 174 105 123
Circle -1 true true 8 87 142
Circle -1 true true 52 157 99
Circle -1 true true 68 91 136
Circle -1 true true 188 263 2
Circle -1 true true 136 194 92

talk
true
15
Polygon -1 true true 9 253 82 153 164 192
Rectangle -1 true true 119 134 142 153
Circle -1 true true 62 24 181
Circle -1 true true 82 6 218
Polygon -1 true true 10 252 159 103 173 216
Rectangle -16777216 true false 155 44 190 134
Rectangle -16777216 true false 155 159 190 184

think
true
15
Circle -1 true true 55 71 60
Circle -1 true true 36 46 89
Circle -1 true true 104 20 99
Circle -1 true true 166 68 98
Circle -1 true true 111 125 90
Circle -1 true true 47 133 87
Circle -1 true true -1 97 83
Circle -1 true true 89 87 98

@#$#@#$#@
NetLogo 2.0.1
@#$#@#$#@
@#$#@#$#@
@#$#@#$#@

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -