📄 wealth.nlogo
字号:
globals[ timestep ; counts how much time has passed]turtles-own[ wealth ; amount of wealth]to setup clear-output ca set timestep 0 cct num-agents [ set wealth 50.0 set color 5 + (10 * (round (wealth / 10))) setxy (random-float screen-size-x) (random-float screen-size-y) ; randomize turtle locations ] setup-plot plot-countsendto go if moving [ move ] give set timestep timestep + 1 plot-countsendto move ask turtles [ rt random-float 30 - random-float 30 fd 5 ]endto give ask turtles [ if wealth > 0 [ set wealth (wealth - 1) ask random-one-of turtles [ set wealth wealth + 1] ifelse wealth < 135.0 [ set color 5 + (10 * (round (wealth / 10))) ] [ set color 135.0 ] ] ]endto plot-counts set-current-plot-pen "wealth" histogram-from turtles [wealth]endto setup-plot set-current-plot "Agent wealth" set-plot-x-range 0 400 set-plot-y-range 0 round ((count turtles) / 5) set-histogram-num-bars 40end@#$#@#$#@GRAPHICS-WINDOW2902270445750504.00101110111CC-WINDOW5479713574Command Center0SLIDER1075248108num-agentsnum-agents101000400101agentsBUTTON6386671setupsetupNIL1TOBSERVERTNILBUTTON703813071gogoT1TOBSERVERTNILPLOT2189282465Agent wealthwealthnumber of agents0.0400.00.0300.0falsetruePENS"wealth" 5.0 1 -5825686 falseMONITOR158126231175Time Steptimestep31SWITCH10119113152movingmoving11-1000BUTTON1433820671stepgoNIL1TOBSERVERTNIL@#$#@#$#@WHAT IS IT?-----------This is a simple economic model. At each time step, each agent picks another agent (at random) and gives that agent one dollar. If an agent has no dollars, it does nothing in that time step and just waits.HOW TO USE IT-------------Each pass through the GO function represents one time step.The histogram shows the number of agents having a given range of wealth.@#$#@#$#@defaulttrue0Polygon -7500403 true true 150 5 40 250 150 205 260 250arrowtrue0Polygon -7500403 true true 150 0 0 150 105 150 105 293 195 293 195 150 300 150boxtrue0Polygon -7500403 true true 45 255 255 255 255 45 45 45circletrue0Circle -7500403 true true 35 35 230personfalse0Circle -7500403 true true 155 20 63Rectangle -7500403 true true 158 79 217 164Polygon -7500403 true true 158 81 110 129 131 143 158 109 165 110Polygon -7500403 true true 216 83 267 123 248 143 215 107Polygon -7500403 true true 167 163 145 234 183 234 183 163Polygon -7500403 true true 195 163 195 233 227 233 206 159spacecrafttrue0Polygon -7500403 true true 150 0 180 135 255 255 225 240 150 180 75 240 45 255 120 135thin-arrowtrue0Polygon -7500403 true true 150 0 0 150 120 150 120 293 180 293 180 150 300 150truck-downfalse0Polygon -7500403 true true 225 30 225 270 120 270 105 210 60 180 45 30 105 60 105 30Polygon -8630108 true false 195 75 195 120 240 120 240 75Polygon -8630108 true false 195 225 195 180 240 180 240 225truck-leftfalse0Polygon -7500403 true true 120 135 225 135 225 210 75 210 75 165 105 165Polygon -8630108 true false 90 210 105 225 120 210Polygon -8630108 true false 180 210 195 225 210 210truck-rightfalse0Polygon -7500403 true true 180 135 75 135 75 210 225 210 225 165 195 165Polygon -8630108 true false 210 210 195 225 180 210Polygon -8630108 true false 120 210 105 225 90 210turtletrue0Polygon -7500403 true true 138 75 162 75 165 105 225 105 225 142 195 135 195 187 225 195 225 225 195 217 195 202 105 202 105 217 75 225 75 195 105 187 105 135 75 142 75 105 135 105@#$#@#$#@NetLogo 3.0beta1@#$#@#$#@@#$#@#$#@@#$#@#$#@@#$#@#$#@
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -