📄 ---model7-grafiek.nlogo
字号:
to count-food;count neighbouring patches with the food the turtle knows about;count this seperately for talkers and seperately for silentsend;;;;;;;;;;;;;;;THE PLOTTING PART;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;to setup-plot set-current-plot "knowledge" set-plot-x-range 0 no-things set-histogram-num-bars no-things set-current-plot "t-s-knowhow" set-plot-x-range 0 no-things set-histogram-num-bars no-thingsendto update-plot;update-plot-a-fupdate-plot-all;update-knowledge;update-t-s-knowhow;update-type-of-foodendto update-plot-a-fset-current-plot "plot-a-f"set-current-plot-pen "line"plotxy (count patches with [ sum here-list = 1]) (count turtles)endto update-plot-alllocals [c];locals [c r]set-current-plot "plot-all"set-current-plot-pen "turtles"plot count turtles set-current-plot-pen "credit"plot (count patches with [sum here-list = 1 ]);plot 0.1 * (count patches with [(first here-list) = 1 ]);set-current-plot-pen "spec-credit";plot 0.2 * (count patches with [ sum (butfirst here-list) = 1]) ;if (count silent > 10 ) ;[set-current-plot-pen "ratio t/s" ; plot 10 * ((count talker) / (count silent))]; [ set r ((count talker) / (count silent)); set-current-plot-pen "ratio t/s"; ifelse (r < 10) [ppd] [ppu] ;;; dont plot if too high; plot 10 * r; ];set-current-plot-pen "en-talkers";if (count talker != 0) [ plot mean values-from talker [energy]];set-current-plot-pen "en-silent";if (count silent != 0) [ plot mean values-from silent [energy]];set-current-plot-pen "know";if (count turtles != 0) [ plot ((sum values-from turtles [sum knowhow]) / (count turtles)) * 10 ];set-current-plot-pen "born";plot born;set-current-plot-pen "died";plot diedend; update the barchartto update-knowledgelocals [l]set l (sum-list (values-from turtles [knowhow])) set l (map [ ( ? / (count turtles)) * 100] l); choose the plotset-current-plot "knowledge"; set the height of the plot;set-plot-y-range 0 (max l); set the width of the plot (will change)set-plot-x-range 0 no; make sure the "default" pen is selectedset-current-plot-pen "default"; reset the plot pen (so plotting starts from the left)plot-pen-reset; make sure it's a bar plotset-plot-pen-mode 1; add bars to the plotforeach (n-values (length l) [ ? ] )[ ; ?1 is indexplot ( item ?1 l )]end ;;suggestion from netlogo users group:;;set things-sum;;map;;[ sum values-from turtles [ item ? things ] ];;( n-values things-length [ ? ] );;give me the number of turtles that know x things:;;or should there be an initial know-list? as extra turtle-own var?;;or should every turtle that knows something from birth just know one thing?;;so the chance is 1/6th * chance per item. First roll dice for slot, then for item;;;;plots the no of turtles that know 1 thing;;to know-hist;;set-current-plot "know" ;;set-plot-y-range 0 count turtles;;histogram-list (values-from turtles [sum knowhow]) ;;endto-report energy-talkersreport mean (values-from talker [energy])endto-report energy-silentreport mean (values-from silent [energy])end;plots number of turtles knowing 1-2-3 etc things, for each breedto update-t-s-knowhowlocals [s t]set-current-plot "t-s-knowhow"set-current-plot-pen "silent"set-plot-pen-mode 1histogram-from silent [add-up knowhow]set-current-plot-pen "talker"set-plot-pen-mode 1histogram-from talker [add-up knowhow]end;plots number of turtles knowing 1-2-3 etc things, for each breedto update-type-of-foodset-current-plot "type-of-food";if (any? silent) [ ; set-current-plot-pen "silent-regular" ;set-plot-pen-mode 1 ;plot silent-reg / ((count silent) / 100) ;set-current-plot-pen "silent-special" ;set-plot-pen-mode 1 ;plot silent-spec / ((count silent) / 100) ];if (any? talker) [ ;set-current-plot-pen "talker-regular" ;set-plot-pen-mode 1 ;plot talker-reg / ((count talker) / 100) ; set-current-plot-pen "talker-special" ;set-plot-pen-mode 1 ; plot talker-spec / ((count talker) / 100) ]end @#$#@#$#@GRAPHICS-WINDOW32110113984950508.01100000CC-WINDOW595611481051Command CenterBUTTON2211031167setupsetupNIL1TOBSERVERTNILPLOT528792728942knowledgeNILNIL0.0100.00.0100.0truefalsePENS"default" 1.0 1 -16777216 falseBUTTON221158310220gogoT1TOBSERVERTNILPLOT1394497676plot-allNILNIL0.0100.00.0100.0truetruePENS"turtles" 1.0 0 -16776961 true"reg-credit" 1.0 0 -65536 true"en-talkers" 1.0 0 -16711681 true"en-silent" 1.0 0 -65281 true"know" 1.0 0 -11352576 true"born" 1.0 0 -65413 true"died" 1.0 0 -16777216 true"spec-credit" 1.0 0 -44544 true"ratio t/s" 1.0 0 -7566196 true"credit" 1.0 0 -16711936 trueMONITOR2340117389ratio talker/silent(count talker)/(count silent)31MONITOR135340213389turtlescount turtles01BUTTON15298104331close filefile-closeNIL1TOBSERVERTNILBUTTON71134168168flipflip-colorNIL1TOBSERVERTNILBUTTON71181167214color offcolor-offNIL1TTURTLETNILBUTTON22183311138go 1xgoNIL1TOBSERVERTNILPLOT746789946939t-s-knowhowno things%0.010.00.0100.0truetruePENS"silent" 1.0 1 -16776961 true"talker" 1.0 1 -65281 trueBUTTON17256131289NILshow-valuesNIL1TOBSERVERTNILPLOT516558916764type-of-foodNILNIL0.030.00.0100.0truetruePENS"silent-regular" 1.0 2 -65536 true"silent-special" 1.0 2 -65413 true"talker-regular" 1.0 2 -16776961 true"talker-special" 1.0 2 -16711681 trueTEXTBOX17685197716special food * 0.2\nregular food * 01BUTTON107300211333add silentsget-silentsNIL1TOBSERVERTNILCHOOSER
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -