Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Info tab incorrectly describes movement in Segregation model #378

Open
ToonTalk opened this issue Jan 17, 2019 · 3 comments
Open

Info tab incorrectly describes movement in Segregation model #378

ToonTalk opened this issue Jan 17, 2019 · 3 comments

Comments

@ToonTalk
Copy link

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
@ToonTalk
Copy link
Author

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

@Falnesio
Copy link

Falnesio commented Jan 17, 2019

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

@ToonTalk
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants