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

📄 ---hotelling-xvila.nlogo

📁 NETLOGO
💻 NLOGO
字号:
; add model procedures herebreeds [people firms]           firms-own [ice-sold-today]people-own [closest]globals [firm1 firm2]to setupcaask random-n-of num-of-people patches  [sprout-people 1 [set color red set shape "person"]]ask random-n-of 2 patches [sprout-firms 1 [set color blue set shape "truck"]]set firm1 num-of-peopleset firm2 (num-of-people + 1)ask turtle firm1 [set color green]endto goask firms [set ice-sold-today 0]if wander? [ask people [do-random-walk]]ask people [  ifelse distance-nowrap turtle firm1 < distance-nowrap turtle firm2    [set closest firm1]    [set closest firm2]    ifelse move-if-close?    [      if distance-nowrap turtle closest < max-distance      [set ice-sold-today-of turtle closest (ice-sold-today-of turtle closest + 1) ]    ]    [      set ice-sold-today-of turtle closest (ice-sold-today-of turtle closest + 1)    ]           ] ifelse random? [ifelse ice-sold-today-of turtle firm2 > ice-sold-today-of turtle firm1 [ask turtle firm1 [ do-random-walk]] [ask turtle firm2 [ do-random-walk]]][ifelse ice-sold-today-of turtle firm2 > ice-sold-today-of turtle firm1 [ask turtle firm1 [ set heading towards-nowrap turtle firm2 fd 1 ]] [ask turtle firm2 [ set heading towards-nowrap turtle firm1 fd 1 ]]] update-plotsendto do-random-walk      rt random-float 360               ; set random heading       forward 1                         ; advance one stependto update-plotsset-current-plot "Ice Sold Today"  set-current-plot-pen "Firm1"  plot ice-sold-today-of turtle firm1  set-current-plot-pen "Firm2"  plot ice-sold-today-of turtle firm2  set-current-plot "Distance Traveled"ifelse move-if-close?[set-current-plot-pen "Max"plot max values-from people with [distance-nowrap turtle closest < max-distance ] [distance-nowrap turtle closest]set-current-plot-pen "Mean"plot mean values-from people with [distance-nowrap turtle closest < max-distance ][distance-nowrap turtle closest]set-current-plot-pen "Min"plot min values-from people with [distance-nowrap turtle closest < max-distance ][distance-nowrap turtle closest]][set-current-plot-pen "Max"plot max values-from people [distance-nowrap turtle closest]set-current-plot-pen "Mean"plot mean values-from people [distance-nowrap turtle closest]set-current-plot-pen "Min"plot min values-from people [distance-nowrap turtle closest]]end@#$#@#$#@GRAPHICS-WINDOW29713863600171715.91101110CC-WINDOW5614872709Command CenterBUTTON1516285196NILsetup\nNIL1TOBSERVERTNILBUTTON195162259196NILgoT1TOBSERVERTNILBUTTON100162187196Go oncegoNIL1TOBSERVERTNILMONITOR17290126339Firm 1 (Green)ice-sold-today-of turtle (num-of-people)01MONITOR131291245340Firm 2 (Blue)ice-sold-today-of turtle (num-of-people + 1)01SLIDER13925842num-of-peoplenum-of-people01000100011NILSWITCH135413487Wander?Wander?11-1000PLOT18349247470Ice Sold TodayNILNIL0.010.00.010.0truefalsePENS"Firm1" 1.0 0 -11352576 true"Firm2" 1.0 0 -16776961 trueTEXTBOX83264191282Ice-cream soldSWITCH1385526088random?random?11-1000PLOT18473246595Distance TraveledNILNIL0.010.00.010.0truefalsePENS"default" 1.0 0 -65536 true"Max" 1.0 0 -65536 true"Mean" 1.0 0 -16776961 true"Min" 1.0 0 -65413 trueSWITCH13102151135move-if-close?move-if-close?01-1000MONITOR1520883257x-Medianmedian values-from people [xcor]31MONITOR91208155257y-Medianmedian values-from people [ycor]31MONITOR225209289258y-Meanmean values-from people [ycor]31MONITOR158208223257x-Meanmean values-from people [xcor]31SLIDER157101284134max-distancemax-distance0481011NIL@#$#@#$#@WHAT IS IT?-----------This model represents a simple extension of the Hotelling spatial competition model by considering two dimensions.HOW IT WORKS------------A "num-of-people" of consumers feel like having an ice-cream that is sold by any of the two firms (firm 1 and firm 2). At each moment, each consumer at a given position goes to the "closest" firm, buys an ice-cream, and returns to its original place.Firms move around the world to attract new consumers. The rules are simple: If I get less consumers that my competitor, the I'll head towards its location.There is the possibility that consumers wander around the world, which is controled by the "wander" switch in the interfaceHOW TO USE IT-------------"Setup" will create a "num-of-people" consumers randomly spread around the world and two firms: firm 1 (green) and firm 2 (blue)"Go" makes firms move around the world to gain consumers as described above"Wander" makes consumers wander aroundEXTENDING THE MODEL-------------------The rule for the movement of the firms is quite simple.New rules should be tried.CREDITS AND REFERENCES----------------------Copyright Xavier Vil

⌨️ 快捷键说明

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