Vee Flocking

No preview image

1 collaborator

Uri_dolphin3 Uri Wilensky (Author)

Tags

(This model has yet to be categorized with any tags)
Model group CCL | Visible to everyone | Changeable by group members (CCL)
Model was written in NetLogo 4.0.1 • Viewed 105 times • Downloaded 9 times • Run 1 time
Download the 'Vee Flocking' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


VERSION

$Id: Vee Flocking.nlogo 37529 2008-01-03 20:38:02Z craig $

WHAT IS IT?

This section could give a general understanding of what the model is trying to show or explain.

HOW IT WORKS

This section could explain what rules the agents use to create the overall behavior of the model.

HOW TO USE IT

This section could explain how to use the model, including a description of each of the items in the interface tab.

THINGS TO NOTICE

This section could give some ideas of things for the user to notice while running the model.

THINGS TO TRY

This section could give some ideas of things for the user to try to do (move sliders, switches, etc.) with the model.

EXTENDING THE MODEL

This section could give some ideas of things to add or change in the procedures tab to make the model more complicated, detailed, accurate, etc.

NETLOGO FEATURES

This section could point out any especially interesting or unusual features of NetLogo that the model makes use of, particularly in the Procedures tab. It might also point out places where workarounds were needed because of missing features.

RELATED MODELS

This section could give the names of models in the NetLogo Models Library or elsewhere which are of related interest.

CREDITS AND REFERENCES

This section could contain a reference to the model's URL on the web if it has one, as well as any other necessary credits or references.

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

turtles-own [ speed ]

to setup
  ca
  crt 30 [
    setxy random-xcor random-ycor
    set heading random 360
    set speed base-speed
    set size 2
    set color red
  ]
end 

to go
  ask turtles [
    set speed base-speed
    if neighbors? [adjust]
    fly
  ]
  tick
end 

to adjust ;; turtle procedure
  ;; if there are birds i see nearby find them
  if ( neighbors? and not close-enough? ) [ set color red seek-neighbors stop ]
  if ( neighbors-too-close? ) [ set color red back-up stop ]
  if ( obstructed-view? ) [ set color red seek-unobstructed-view stop ]
  line-up
end 

to fly
  fd speed
end 

to-report neighbors?
  if( any? myneighbors )
    [ report true ]
  report false
end 

to-report myneighbors
  report turtles in-cone view-distance vision-cone with [ self != myself ]
end 

to-report myneighbor
  let me self
  report min-one-of myneighbors [ distance me ]
end 

to-report close-enough?
  let me self
  if any? myneighbors with [ distance me < drift-distance ]
    [ report true ]
  report false
end 

to seek-neighbors ;; turtle procedure
  turn-towards [heading] of myneighbor
  set speed base-speed * 1.25
end 

to-report neighbors-too-close?
  let me self
  report any? myneighbors with [ distance me < too-close ]
end 

to back-up
  set speed base-speed * .75
end 

to-report obstructed-view?
  ifelse any? turtles in-cone view-distance obstruction-angle with [self != myself]
    [ report true ]
    [ report false ]
end 

to seek-unobstructed-view
  turn-away [heading] of myneighbor
  ;set speed base-speed * 1.2
end 

to line-up
  set speed [ speed ] of myneighbor
  if viz? [set color white]
  ;set heading [heading] of myneighbor
end 

to turn-towards [new-heading]  ;; turtle procedure
  turn-at-most (subtract-headings new-heading heading)
end 

to turn-away [new-heading]  ;; turtle procedure
  turn-at-most ( random ( max-turn * 2 ) - max-turn )
end 

to turn-at-most [turn]  ;; turtle procedure
  ifelse abs turn > max-turn
    [ ifelse turn > 0
        [ rt max-turn ]
        [ lt max-turn ] ]
    [ rt turn ]
end 

There is only one version of this model, created over 8 years ago by Uri Wilensky.

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.