?? ---friends-xvila.nlogo
字號:
; add model procedures hereturtles-own [friends happy]globals [welfare groups total average]to setupcaask random-n-of people patches [sprout 1 [set color red set shape "person"]]ask patches [set pcolor green]endto goset welfare 0set groups 0set total 0ask turtles [set friends 0]ifelse max-friends?[ask turtles [ifelse (count turtles-here >= friends-wanted + 1) and (count turtles-here <= friends-wanted-max + 1) [set friends friends + count turtles-here - 1 set happy 1 set welfare welfare + happy] [move]]][ask turtles [ifelse count turtles-here >= friends-wanted + 1 [set friends friends + count turtles-here - 1 set happy 1 set welfare welfare + happy] [move]]]ask patches [if any? turtles-here[set groups groups + 1]]ask patches [if any? turtles-here[set total total + count turtles-here]]set average total / groupsif welfare = people[stop]update-plotsendto movert random 10lt random 10fd 1end to update-plotsset-current-plot "Happy people"set-current-plot-pen "Happy people"plot welfareset-current-plot-pen "groups"plot groupsend@#$#@#$#@GRAPHICS-WINDOW37513805464171712.01101110CC-WINDOW5478814573Command CenterBUTTON39145108178NILsetupNIL1TOBSERVERTNILBUTTON118146181179NILgoT1TOBSERVERTNILSLIDER355920792friends-wantedfriends-wanted010211NILMONITOR19200127249Happy Turtleswelfare31SLIDER331320546peoplepeople21005011NILPLOT15265215415Happy peopleNILHappy0.010.00.050.0truefalsePENS"default" 1.0 2 -16745473 true"Happy people" 1.0 0 -16745473 true"groups" 1.0 0 -44544 trueMONITOR137200199249Groupsgroups31SLIDER35101222134friends-wanted-maxfriends-wanted-max020911NILSWITCH2191536548max-friends?max-friends?01-1000MONITOR229196373245Average Group SIzeaverage31@#$#@#$#@WHAT IS IT?-----------This model works in the opposite direction of the Seggregation model in the Netlogo's Social Sciences library.Here, people wants to gather together in gropus of "friends" while wandering around the canvasHOW IT WORKS------------People wanders around the worls until the moment they meet with the number of friends they are expecting.If "max-friends" is turned on, then they also care for a maximum number of friends in the group, departing the group if the number of friends is about this maximum thresholdHOW TO USE IT-------------Use the slider to select the number of friends wanted and, if desired, the maximum number of friends wanted in the groupTHINGS TO NOTICE----------------If the number of friends wanted is to high, chances are that they'll never get itTHINGS TO TRY-------------Start with a low number of friends wanted (2 or so) once the model reaches some stability start trying with high numbers (without stopping the model!!)Once stability is reached, turn on the max-friends switch and play around with the friends-wanted-max parameter. Chances are that some groups will break apartEXTENDING THE MODEL-------------------Do your ownNETLOGO FEATURES----------------The model was developed for teaching purposes. Hence, it's very simpleCREDITS AND REFERENCES----------------------Copyright Xavier Vil
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -