grocery ++

No preview image

2 collaborators

Default-person Maxim Derkach (Author)
Default-person Janika D. (Author)

Tags

(This model has yet to be categorized with any tags)
Child of model maximShop
Model group ResiliBaem | Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.1.1 • Viewed 83 times • Downloaded 9 times • Run 0 times
Download the 'grocery ++' 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

turtles-own [
  house
  goal
  collected-heat
  age
  car-like ;: value 1-10
  pubble-like ;: value 1-10
  walk-like ;: value 1-10
  bike-like ;: value 1-10
  ]

workers-own[
  workplace
  work-from-home
  has-children
  has-car
]

seniors-own[
  has-car
]

children-own[
  p-school
]

patches-own [
  popularity ;; unnötig
  trafficStop
  land-cover ; if value 1 = building, if value 2 = road, if value 3 = green area
  temperature
  sales ;; from grocery
  ]

globals [buildings
  populous
 ; work-home-distance ; crasht mit dem interface variable
]


breed [
  workers
  worker
]

breed [
  seniors
  senior
]

breed [
  children
  child
]

to setup
  clear-all
  reset-ticks
  import-pcolors "traffic.png"
  ask patches [
   if pcolor = 104 [set trafficStop 1]
  ]
    import-pcolors "heat0.png"
    ask patches [set temperature pcolor]
    import-pcolors "landcover.png"
    ask patches [
      (ifelse pcolor = green [set land-cover 3]
        pcolor = yellow [set land-cover 1]
        pcolor = grey [set land-cover 2]
        )
    ]
  set buildings (list)
  ask patches [
    set pcolor green
    set popularity 1
    set temperature 0
    set sales 0
  ]
  ask patch (random-xcor)(random-ycor) [become-building]
  ;create-turtles walker-count [
   ; set xcor random-xcor
    ;set ycor random-ycor
   ; set house one-of patches
    ;set goal one-of patches
    ;set color blue
    ;set size 2
    ;set collected-heat 1
  ;]
  create-workers initial-number-workers
[
    set collected-heat random (temperature)
    let places patches with [ land-cover = 1] ; ist es sinnvoller das global zu machen?
    set house one-of places ; home-base patch
    set workPlace one-of places with [distance house < work-home-distance]  ;with expected this input to be a true/false block but got a true/false instead
    set work-from-home random 2 ;uU mit % in commuteRange integrierbar, e.g. commuteRange = X with Y% workfromhome
    set has-children random 5 ; % o.ä. einbauen, aktiviert Kita(s) als Ziel, erhöht shop use, etc
    set has-car random 2 ; einbauen %Wert, use limit : X% Straßenpatches + uU theoretische Garagen?
    set car-like random 11 ;uU noch eingrenzen, Test if necessary..
    set pubble-like random 11 ; s.o.
    set bike-like random 11
    set walk-like random 11
 ; goal ; uU use to build travelroute
  ]
end 



;; Click to place buildings
;; Have stuff unbecome path once it decays below a certain popularity threshold

to go
  check-building-placement
  move-walkers
  decay-popularity
  tick
end 

to check-building-placement
  if mouse-down?
  [ask patch (round mouse-xcor) (round mouse-ycor) [
    ifelse pcolor = red
    [ unbecome-building ]
    [ become-building ]
  ]]
end 

to unbecome-building
  set pcolor green
  set popularity 1
  set buildings (remove self buildings)
  set temperature 0
end 

to become-building
  set pcolor red
  set buildings (fput self buildings)
  set temperature work-temperature
end 

to decay-popularity
  ask patches with [pcolor != red] [
    if popularity > 1 and not any? turtles-here [ set popularity popularity * (100 - popularity-decay-rate) / 100 ]
    ifelse pcolor = green
    [ if popularity < 1 [ set popularity 1 ] ]
    [ if popularity < 1 [
        set popularity 1
        set pcolor green
        ] ]
  ]
end 

to become-more-popular
  set popularity popularity + popularity-per-step
  if popularity > minimum-route-popularity [ set pcolor gray ]
end 

to move-walkers
  ask turtles [
    set collected-heat collected-heat + .1
    ifelse patch-here = goal
      [ ifelse pcolor = red
        [ifelse collected-heat >= temperature
          [set collected-heat collected-heat - temperature
           set goal house
           ask patch-here [set sales sales + 1]]
          [ifelse coin-flip? [set goal one-of buildings] [set goal one-of patches] ] ]
        [ifelse coin-flip? [set goal one-of buildings] [set goal one-of patches] ] ]
      [ walk-towards-goal ] ]
end 

to-report coin-flip?
  report random 2 = 0
end 

to walk-towards-goal
  let last-distance distance goal
  let best-route-tile route-on-the-way-to goal last-distance

  ; boost the popularity of the route we're using
  if pcolor = green
  [ ask patch-here [become-more-popular] ]

  ifelse best-route-tile = nobody
  [ face goal ]
  [ face best-route-tile ]
  fd 1
end 

to-report route-on-the-way-to [l current-distance]
  let routes-on-the-way-to-goal (patches in-radius walker-vision-dist with [
      pcolor = gray and distance l < current-distance - 1
    ])
  report min-one-of routes-on-the-way-to-goal [distance self]
end 

There are 2 versions of this model.

Uploaded by When Description Download
Janika D. about 3 years ago interface added Download this version
Maxim Derkach about 3 years ago aktueller stand Download this version

Attached files

No files

Parent: maximShop

This model does not have any descendants.

Graph of models related to 'grocery ++'