NetLogo/models

Info tab incorrectly describes movement in Segregation model

ToonTalk opened this issue · 3 comments

Info tab says "If agents don’t have enough same-color neighbors, they move to a nearby patch. "

and yet the code is

; move until we find an unoccupied spot
to find-new-spot
  rt random-float 360
  fd random-float 10
  if any? other turtles-here [ find-new-spot ] ; keep going until we find an unoccupied patch
  move-to patch-here  ; move to center of patch
end

And why this complexity? Could just jump to any empty patch...

I think the info tab is correct. Don't know why not to just jump to any empty patch (EDIT: could be to make turtles remain close to their neighborhood, maybe mimic house hunting).

; run the model for one tick
to go
  if all? turtles [ happy? ] [ stop ]
  move-unhappy-turtles <---------------------this
  update-turtles
  update-globals
  tick
end

; unhappy turtles try a new spot
to move-unhappy-turtles
  ask turtles with [ not happy? ]
    [ find-new-spot ] <------------------------leads to this
end

to update-turtles
  ask turtles [
    ; in next two lines, we use "neighbors" to test the eight patches
    ; surrounding the current patch
    set similar-nearby count (turtles-on neighbors)  with [ color = [ color ] of myself ]
    set other-nearby count (turtles-on neighbors) with [ color != [ color ] of myself ]
    set total-nearby similar-nearby + other-nearby
    set happy? similar-nearby >= (%-similar-wanted * total-nearby / 100) <-------------if this shows that the turtle is unhappy on the last tick
    ; add visualization here
    if visualization = "old" [ set shape "default" set size 1.3 ]
    if visualization = "square-x" [
      ifelse happy? [ set shape "square" ] [ set shape "X" ]
    ]
  ]
end

I guess this depends on what one thinks "nearby" means. It can go fd up to 10 steps in a 51x51 space for each attempt to find a free space. And with the default density of 95% it will do this on average 10 times before finding an empty space.