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

📄 ---graze1.nlogo

📁 NETLOGO
💻 NLOGO
📖 第 1 页 / 共 2 页
字号:
globals [biomass-unit days dollars grazecountdown mcal]breeds [cow]patches-own [biomass]turtles-own [energy] ; as Mcalto setup    ca    set biomass-unit 2.5 ; each increment of biomass (0-10) is valued at this many lbs. dry weight     ifelse start-patches-even?        [ask patches [set biomass 4]]        [ask patches [set biomass (random 4.0) * 2]]    if update-patches?    [ask patches [update-patches]]    setup-plot    setup-histogramendto go   ask patches [grow-grass-and-weeds               cycle-plants]   if update-patches?   [ask patches [update-patches]]   plot-biomass   histo-patches   set days days + 1   set grazecountdown grazecountdown - 1   wait 0.5   if any turtles        [ ask cow [graze] ]endto cycle-plants ;; patch procedure representing mortality and new establishment      if biomass <= .3 [      if ( random 100 ) < 5        [ set biomass 0 ]                       ]              if biomass = 0 [        if ( random 100 ) < 3        [ set biomass 1 ]                     ]endto update-patches ;; patch procedure    if biomass <= 2 [set pcolor 68]     if biomass > 2 [set pcolor 66]    if biomass > 6 [set pcolor 64]    if biomass > 8 [set pcolor 44]    if biomass <= 0 [set pcolor brown] endto cattle-in    set-default-shape cow "cow"    create-custom-cow num-cows  ;; create the cows, then initialize their variables          [     set color black    set energy 0    setxy (random screen-size-x) (random screen-size-y) ; spreads them around    rt random 360          ]     set grazecountdown grazeperiod   endto cattle-out    ask turtles [die]    set grazecountdown 0end;;;;; GRAZING PROCEDURESto graze  ;; daily cow procedure   if grazecountdown <= 0 [die]   repeat (.4 / bitesize) [move bite]   check-fill   gainend                            to move                                    rt random 50 - random 50 fd 1    repeat selectivity        [    if biomass < 1 or biomass > 8 [fd 3]        ]endto bite       ifelse biomass < 1 or biomass > 8        [  set energy energy + (biomass * biomass-unit * bitesize * .4)] ; less energy: .4 Mcal per lb.       [  set energy energy + (biomass * biomass-unit * bitesize * .7)] ; more energy: .7 Mcal per lb.       set biomass (biomass * (1 - bitesize)) ; patch loses biomass in proportion to bitesize   endto check-fill    repeat (1.6 / bitesize) [if energy < 20 [move bite]] ; attempt to harvest 20 Mcalendto gain    set dollars dollars + (((energy - 5) / 7) * .4)     ;assumes 5 Mcal for maintenance    ;assumes 7 Mcal needed for pound of $.40 gain    set mcal energy; records the energy harvest of last cow    set energy 0end;;;;; PLANT GROWTHto grow-grass-and-weeds ;; patch procedure    if biomass < 7.5 ;; stage at which growth slows    [set biomass biomass + (((precision (biomass ^ .667) 2) / 40) * grassrate)]     ; gives about 2.5% daily growth with grassrate 1.0    if biomass >= 7.5     [set biomass biomass + (((10 - biomass) / 40) * grassrate)]end;;;; PLOTTING PROCEDURESto setup-plot    set-current-plot "ecology and economy"    set-current-plot-pen "avg-biomass"    set-plot-y-range 0 10    set-current-plot-pen "dollars per week"    set-plot-y-range 0 10endto setup-histogram    set-current-plot "patch biomass histogram"    ;set-plot-x-range 0 10    set-plot-y-range 0 100    set-histogram-num-bars 11endto plot-biomass     set-current-plot "ecology and economy"    set-current-plot-pen "avg-biomass"    plot mean values-from patches [biomass]    set-current-plot-pen "dollars per week"    plot dollars / (days + .001) * 7endto histo-patches    set-current-plot "patch biomass histogram"    histogram patches [ biomass ]  ; using the default plot penend; ***NetLogo Model Copyright Notice***; Copyright 2003 by Peter Donovan. All rights reserved.; Permission to use, modify, or redistribute this model is hereby granted,; provided that both of the following requirements are followed:; a) this copyright notice is included.; b) this model will not be redistributed for profit without permission;    from Peter Donovan.; Contact Peter Donovan (peter@managingwholes.com) for appropriate licenses; for redistribution for profit.; To refer to this model in academic publications, please use: ; Donovan, Peter. (2003).  NetLogo Grazing Model # 1. ; http://managingwholes.com/models/graze1.htm.@#$#@#$#@GRAPHICS-WINDOW324106643508820.011000CC-WINDOW324547664677Command CenterBUTTON20108543setupsetupNIL1TOBSERVERBUTTON891114944rungoT1TOBSERVERMONITOR1591221661daysdays01SLIDER20153154186num-cowsnum-cows01001011NILBUTTON204712980advance 1 daygoNIL1TOBSERVERBUTTON19189122236cattle incattle-inNIL1TOBSERVERPLOT19393664543ecology and economydaysNIL0.0365.00.010.0truetruePENS"avg-biomass" 1.0 0 -8716033 true"dollars per week" 1.0 0 -65536 trueMONITOR2251231061dollarsdollars21PLOT19247311384patch biomass histogram<= seedlings      dormant =># patches0.010.00.0100.0truefalsePENS"default" 1.0 1 -16777216 trueSLIDER1983153116grassrategrassrate03.01.00.11NILSLIDER159153311186grazeperiodgrazeperiod01001011NILMONITOR237188311237recovery0 - grazecountdown01BUTTON126189233236cattle outcattle-outNIL1TOBSERVERMONITOR23165309114$ per daydollars / days21SWITCH324359467392update-patches?update-patches?01

⌨️ 快捷键说明

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