Wealth and residence

Wealth and residence preview image

1 collaborator

Default-person Hossein Sabzian (Author)

Tags

social science 

Tagged by Hossein Sabzian 5 months ago

Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.0.1 • Viewed 129 times • Downloaded 5 times • Run 0 times
Download the 'Wealth and residence' 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 [
wealth  ;; the wealth of each person
happy?  ;; the state of happiness and when people are at their related residence, they feel happy otherwise they feel unhappy
]
;;;;;;;;;;;;;;;;;;;;setup procedure

to setup
  ca
  set-default-shape turtles "person"
  ask patches [ set pcolor green + 3]  ;; color of patches
  ask patches with [pxcor = 0 or pycor = 0 ] [ set pcolor white]  ;;seperating lines
  crt num-of-people  [
           set happy? false  ;; they are unhappy in the initial conditions
           setxy random-xcor random-ycor  ;; people's spatial distribution
           set wealth random 100  ;; people get a value of wealth in a random manner
           recolor ;; people set their color based on their wealth
  ]
  reset-ticks
end 

;;;;;;;;;;;;;;;;;;;;go procedure

to go
if all? turtles [happy?] [stop]  ;; if all people are at their related residence they all get happy and model stopes
  ask turtles with [not happy?] [
    ;; move procedure
        move-to-find
    ;; if wealth of a person is less than 25 units, he or she will go to southeast of the city to find a suitable residence
        if wealth < 25 [go-to-southeast]
    ;; if wealth of a person is greater than or equal to 25 units and less than 50 units, he or she will go to southwest of the city to find a suitable residence
        if wealth >= 25 and wealth < 50  [go-to-southwest]
    ;; if wealth of a person is greater than or equal to 50 units and less than 75 units, he or she will go to northeast of the city to find a suitable residence
        if wealth >= 50 and wealth < 75 [go-to-northeast]
    ;; if wealth of a person is greater than or equal to 75 units and less than 100 units, he or she will go to northwest of the city to find a suitable residence
        if wealth >= 75 and wealth < 100 [go-to-northwest]
  ]


tick
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;helper procedures

to go-to-southeast   ;; if they are at the southeast, get stabilised otherwise move to find the southeastern area
  ifelse ((pxcor > 0 and pycor < 0) ) [
   stabilise
  ]
  [ move-to-find ]
end 

to go-to-southwest ;; if they are at the southwest, get stabilised otherwise move to find the southwestern area
    ifelse ((pxcor < 0 and pycor < 0) ) [
   stabilise
  ]
  [ move-to-find ]
end 

to go-to-northeast ;; if they are at the northeast, get stabilised otherwise move to find the northeastern area
  ifelse ((pxcor > 0 and pycor > 0) ) [ stabilise
  ]
  [ move-to-find ]
end 

to go-to-northwest ;;;; if they are at the northwest, get stabilised otherwise move to find the northwestern area
    ifelse ((pxcor < 0 and pycor > 0) ) [
   stabilise
  ]
  [ move-to-find ]
end 

to move-to-find  ;; move procedure, a turtle-procedure
  rt random 90
  lt random 90
  if not can-move? 1 [ rt 180 ]
  fd 1
end 

to stabilise  ;; stabilise procedure, a turtle-procedure
  ifelse not any? other turtles-here [
    set happy? true setxy pxcor pycor ]
  [ move-to-find ]
end 

to recolor  ;; coloring procedure, a turtle-procedure

if wealth < 25 [set color orange] ;; people with a wealth value less than 25 units get an orange color
if wealth >= 25 and wealth < 50  [set color cyan]  ;; peolpe with a wealth value greater than or equal to 25 units and less than 50 units, they get a cyan color
if wealth >= 50 and wealth < 75 [set color green ] ;; peolpe with a wealth value greater than or equal to 50 units and less than 75 units, they get a green color
if wealth >= 75 and wealth < 100 [set color magenta] ;; peolpe with a wealth value greater than or equal to 75 units and less than 100 units, they get a magenta color
end 

There is only one version of this model, created 5 months ago by Hossein Sabzian.

Attached files

File Type Description Last updated
Wealth and residence.png preview Preview for 'Wealth and residence' 5 months ago, by Hossein Sabzian Download

This model does not have any ancestors.

This model does not have any descendants.