Competing Technologies (iPhone vs Blackberry) v2

No preview image

1 collaborator

Default-person Felix Hu (Author)

Tags

(This model has yet to be categorized with any tags)
Model group MAM-2013 | Visible to everyone | Changeable by everyone
Model was written in NetLogo 5.0.4 • Viewed 230 times • Downloaded 22 times • Run 0 times
Download the 'Competing Technologies (iPhone vs Blackberry) v2' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

breed [customers customer]
turtles-own [group-pref tech-pref influence-by-marketing]
globals [iphone-resources blackberry-resources tech-iphone tech-blackberry iphone-upgrade-cost blackberry-upgrade-cost]

to setup
  clear-all
  
  set iphone-resources 0
  set blackberry-resources 0
  set tech-blackberry 0
  set tech-iphone 0
  set iphone-upgrade-cost 2000
  set blackberry-upgrade-cost 2000
  
  set-default-shape customers "circle"
  create-customers initial-customers [
    ifelse random 100 < initial-iphone-percent [
      set color orange
    ][
      set color magenta
    ]
    create-helper
  ]
  ask turtles [
    if random 100 < isolation [
      create-links
    ]
  ]
  ask patches [
    set pcolor 5
  ]
  setup-marketing
  reset-ticks
end 

to create-helper
  setxy random-xcor random-ycor
  set size .5
  set group-pref random 20
  set tech-pref random 20
  set influence-by-marketing random 20
end 

to go
  add-resources
  spend-resources
  
  if ticks mod 5000 = 0 [
    create-customers 1 [
      create-helper
      create-links
      set-phone-choice
    ]
  ]
  if ticks mod 100000 = 0 [
    ask customers [
      set-phone-choice
    ]
  ]
  tick
end 

to add-resources
  set iphone-resources iphone-resources + count turtles with [color = orange]
  set blackberry-resources blackberry-resources + count turtles with [color = magenta]
end 

to spend-resources 
  if iphone-resources > iphone-upgrade-cost [
    ifelse random iphone-tech-spending + iphone-marketing-spending < iphone-tech-spending [
      set tech-iphone tech-iphone + 1
    ][
      if any? patches with [pcolor != 109] [
        ask one-of patches with [pcolor != 109] [
          increase-iphone-patch
        ]
      ]
    ]
    set iphone-resources iphone-resources - iphone-upgrade-cost
    ;set iphone-upgrade-cost iphone-upgrade-cost * 1
  ]
  if blackberry-resources > blackberry-upgrade-cost [
    ifelse random blackberry-tech-spending + blackberry-marketing-spending < blackberry-tech-spending [
      set tech-blackberry tech-blackberry - 1
    ][
      if any? patches with [pcolor != 100] [
        ask one-of patches with [pcolor != 100] [
          increase-blackberry-patch
        ]
      ]
    ]
    set blackberry-resources blackberry-resources - blackberry-upgrade-cost
    ;set blackberry-upgrade-cost blackberry-upgrade-cost * 1
  ]
end 

to increase-iphone-patch
  let my-color pcolor
  ifelse any? neighbors with [pcolor < my-color] [
    ask one-of neighbors [
      if pcolor != 109 [
        set pcolor pcolor + 1
      ]
    ]
  ][
    ask one-of patches with [pcolor != 109] [increase-iphone-patch]
  ]
end 

to increase-blackberry-patch
  let my-color pcolor
  ifelse any? neighbors with [pcolor < my-color] [
    ask one-of neighbors [
      if pcolor != 100 [
        set pcolor pcolor - 1
      ]
    ]
  ][
    ask one-of patches with [pcolor != 100] [increase-blackberry-patch]
  ]
end 

to set-phone-choice 
  set-according-to-neighbors
  set-according-to-tech
  set-according-to-marketing
end 

to set-according-to-neighbors
  let blackberry-neighbors 0
  let iphone-neighbors 0
  if any? link-neighbors [
    ask link-neighbors [
      if color = magenta [
        set blackberry-neighbors blackberry-neighbors + 1
      ]
      if color = orange [
        set iphone-neighbors iphone-neighbors + 1
      ]
    ]
  ]
  let sum-of-preferences (count link-neighbors) * group-pref
  ifelse random sum-of-preferences < blackberry-neighbors * group-pref [
    set color magenta
  ][
    set color orange
  ]
end 

to set-according-to-tech
  if random 20 < tech-pref [
    ifelse random tech-iphone + tech-blackberry < tech-iphone [
      set color orange
    ][
      set color magenta
    ]
  ]
end 

to set-according-to-marketing
  if random 20 < influence-by-marketing [
    ifelse random 10 < pcolor - 100 [
      set color orange
    ][
      set color magenta
    ]
  ]
end 

to setup-marketing
  ask one-of patches [
    set pcolor 104
    ask-neighbors
  ]
end 

to ask-neighbors
  let my-color pcolor
  ask neighbors [
    if pcolor = 5 [
      ifelse random (iphone-marketing-spending + blackberry-marketing-spending) < iphone-marketing-spending [
        ifelse my-color + 1 > 109 [
          set pcolor 109
        ][
          set pcolor my-color + 1
        ]
      ][
        ifelse my-color - 1 < 100 [
          set pcolor 100
        ][
          set pcolor my-color - 1
        ]
      ]
      ask-neighbors
    ]
  ]
end 

to create-links 
  if random 100 < isolation [
    repeat random network-density [create-link-with one-of other turtles in-radius 50] 
  ]
end 

There is only one version of this model, created almost 11 years ago by Felix Hu.

Attached files

File Type Description Last updated
FelixHu_June2.docx word Update on how the model has developed almost 11 years ago, by Felix Hu Download