The American Dream

No preview image

1 collaborator

205711_10151375508175742_13326217_n Kalonji Nzinga (Author)

Tags

(This model has yet to be categorized with any tags)
Parent of 1 model: The American Dream 2
Model group LS426_2013 | Visible to everyone | Changeable by group members (LS426_2013)
Model was written in NetLogo 5.0.3 • Viewed 386 times • Downloaded 21 times • Run 0 times
Download the 'The American Dream' 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

globals [
  percent-similar-
  quad1resources
  quad2resources
  quad3resources
  quad4resources
  quad5resources
  quad6resources
  quad7resources
  quad8resources
  quad9resources
  quad0turtles
  quad0turtles1
  quad0turtles2
  quad0turtles3
  quad0turtles4
  quad0turtles5
  quad0turtles6
  quad4classlow
  quad4classmid
  quad4classhigh
  quad7ethnicityorange
  quad7ethnicityblue
  quad1turtles
  quad2turtles
  quad3turtles
  quad4turtles
  quad5turtles
  quad6turtles
  quad7turtles
  quad8turtles
  quad1satis
  quad2satis
  quad3satis
  quad4satis
  quad5satis
  quad6satis
  quad7satis
  quad8satis
  quad9satis
]
  
  
turtles-own [
  satisfied   ;; for each turtle, indicates whether or not it is satisfied with its current position 
  racialsatisfaction
  classsatisfaction
  blue?    ;; for each tu
  orange?
  upper-class?
  middle-class?
  lower-class?
  group
  class
  resources
  similar-ethnicity-nearby
  other-ethnicity-nearby
  acceptable-resource-nearby
  desired-class-nearby
  total-nearby
  percent-ethnicity-nearby
  percent-class-nearby
  tquadrant
  destinationperc
  destination
  choice1hap
  choice2hap
  choice3hap
  income
]

patches-own [
  presources
  quadrant
  open?
]

to update-turtles
 
 ask turtles [
   if blue? 
    [set similar-ethnicity-nearby count (turtles in-radius 3)
     with [blue? = true]
     set other-ethnicity-nearby count (turtles in-radius 3)
     with [orange? = true]]
   if orange? 
    [set similar-ethnicity-nearby count (turtles in-radius 3)
     with [orange? = true]
    set other-ethnicity-nearby count (turtles in-radius 3)
     with [blue? = true]]
    set total-nearby (similar-ethnicity-nearby + other-ethnicity-nearby)
    set percent-ethnicity-nearby (similar-ethnicity-nearby / total-nearby)
     ifelse similar-ethnicity-wanted > percent-ethnicity-nearby
    [set racialsatisfaction 1 - (similar-ethnicity-wanted - percent-ethnicity-nearby)]
    [set racialsatisfaction 1]
    set percent-class-nearby (desired-class-nearby / total-nearby) 
     ifelse class-level-desired > percent-class-nearby
    [set classsatisfaction 1 - (class-level-desired - percent-class-nearby)]
    [set classsatisfaction 1]
  if upper-class?
  [set desired-class-nearby count (turtles in-radius 3)
    with [upper-class? = true]]
   if middle-class?
  [set desired-class-nearby count (turtles in-radius 3)
    with [upper-class? = true]]
  if lower-class?
  [set desired-class-nearby count (turtles in-radius 3)
    with [middle-class? = true]]
   set satisfied percent-ethnicity * racialsatisfaction + (1 - percent-ethnicity) * classsatisfaction
   set tquadrant quadrant
  
 ]
end 

to assign-quadrant
  ask patches [
  if pxcor <= -8 and pxcor > -25 and pycor <= 25 and pycor > 8 [set quadrant 0 set pcolor 1]
  if pxcor <= 8 and pxcor > -8 and pycor <= 25 and pycor > 8 [set quadrant 1 set pcolor 3]
  if pxcor <= 25 and pxcor > 8 and pycor <= 25 and pycor > 8 [set quadrant 2 set pcolor 1]
  if pxcor <= -8 and pxcor > -25 and pycor <= 8 and pycor > -8 [set quadrant 3 set pcolor 3]
  if pxcor <= 8 and pxcor > -8 and pycor <= 8 and pycor > -8 [set quadrant 4 set pcolor 1]
  if pxcor <= 25 and pxcor > 8 and pycor <= 8 and pycor > -8 [set quadrant 5 set pcolor 3]
  if pxcor <= -8 and pxcor > -25 and pycor <= -8 and pycor > -25 [set quadrant 6 set pcolor 1]
  if pxcor <= 8 and pxcor > -8 and pycor <= -8 and pycor > -25 [set quadrant 7 set pcolor 3]
  if pxcor <= 25 and pxcor > 8 and pycor <= -8 and pycor > -25 [set quadrant 8 set pcolor 1]]
end 

to calc-quad-satis [quad groupnum]
end 

to setup
  clear-all
  if number > count patches
   [ user-message (word "This city only has room for" count patches " turtles .")
      stop ]
   
   ;; create turtles on random patches.
   ask n-of number patches
    [ sprout 1
       [ set color 27] ]
    ;; turn
   ask turtles [
    if xcor <= 25 and xcor > 16 [set group 1 set color 27]
    if xcor <= 16 and xcor > 8 [set group 2 set color 25]
    if xcor <= 8 and xcor > 0 [set  group 3 set color 22]
    if xcor <= 0 and xcor > -8 [set group 4 set color 86]
    if xcor <= -8 and xcor > -16 [set group 5 set color 93]
    if xcor <= -16 and xcor >= -25 [set group 6 set color 102]
     find-fresh-patch
    set orange? color = 27 or color = 25 or color = 22   
    set blue?   color = 86 or color = 93 or color = 102
    set upper-class? color = 22 or color = 102
    set middle-class? color = 25 or color = 93
    set lower-class? color = 27 or color = 86
    if upper-class? [set resources 100]
    if middle-class? [set resources 50]
    if lower-class? [set resources 25]
    if color = 22 or color = 102 [set class 1]
    if color = 25 or color = 93 [set class 2]
    if color = 27 or color = 86 [set class 3]
   ]
   assign-quadrant
   reset-ticks
end 

to go
  update-turtles
  update-patches
  update-globals
  move-turtles
  tick
end 

to update-patches
 ask patches [
 set open? not any? turtles-here
 ]
end 

to move-turtles
  ask turtles [
  let choice1 random 8
  let choice2 random 8
  let choice3 tquadrant;; generate 3 random quadrants that a turtle has knowledge of. these are candidates for movement (need to set choice 3 to own quadrant)
  set choice1hap .35
  if any? turtles with [group = [group] of myself and tquadrant = choice1]
  [set choice1hap mean [satisfied] of turtles with [group = [group] of myself and class = [class] of myself and tquadrant = choice1]] ;? true] ;and turtles-on patch with [quadrant = choice1]
  set choice2hap .35
  if any? turtles with [group = [group] of myself and tquadrant = choice2]
  [set choice2hap mean [satisfied] of turtles with [group = [group] of myself and class = [class] of myself and tquadrant = choice2]] ;and turtles-on patch with [quadrant = choice2]
  set choice1hap .35
  if any? turtles with [group = [group] of myself and tquadrant = choice3]
  [set choice3hap mean [satisfied] of turtles with [group = [group] of myself and class = [class] of myself and tquadrant = choice3]] ;and turtles-on patch with [quadrant = choice3]

  ifelse choice1hap >= choice2hap
  [ifelse choice1hap >= choice3hap 
    [set destination choice1 set destinationperc choice1hap]
    [set destination choice3 set destinationperc choice3hap]]
  [ifelse choice2hap >= choice3hap
    [set destination choice2 set destinationperc choice2hap]
    [set destination choice3 set destinationperc choice3hap]]
  let destinations destination
  
  if destinationperc > satisfied
   [let rangen random 6
  if rangen = 2 [
  if any? patches with [quadrant = destinations and open? = true]
  [move-to one-of patches with [quadrant = destinations and open? = true]
    if not open? [move-turtles]]
  if any? other turtles-here
      [find-fresh-patch2]
      move-to patch-here
    ]]]
  ;; move to the quandrant where turtles of the same kind are happiest
end 

to find-fresh-patch
rt random-float 360
     fd random-float 100
     if any? other turtles-here
      [find-fresh-patch]
      move-to patch-here
end 

to find-fresh-patch2
rt random-float 360
     fd random-float 5
     if any? other turtles-here
      [find-fresh-patch2]
      move-to patch-here
end 

to update-globals 
 set quad0turtles1 count turtles with [group = 1] with [tquadrant = 0]
 set quad0turtles2 count turtles with [group = 2] with [tquadrant = 0]
 set quad0turtles3 count turtles with [group = 3] with [tquadrant = 0]
 set quad0turtles4 count turtles with [group = 4] with [tquadrant = 0]
 set quad0turtles5 count turtles with [group = 5] with [tquadrant = 0]
 set quad0turtles6 count turtles with [group = 6] with [tquadrant = 0]
 set quad4classlow count turtles with [group = 1 or group = 4] with [tquadrant = 4]
 set quad4classmid count turtles with [group = 2 or group = 5] with [tquadrant = 4]
 set quad4classhigh count turtles with [group = 3 or group = 6] with [tquadrant = 4]
 set quad7ethnicityorange count turtles with [group = 1 or group = 2 or group = 3] with [tquadrant = 7]
 set quad7ethnicityblue count turtles with [group = 4 or group = 5 or group = 6] with [tquadrant = 7]
end 

There is only one version of this model, created over 12 years ago by Kalonji Nzinga.

Attached files

No files

This model does not have any ancestors.

Children:

Graph of models related to 'The American Dream'