Move Towards Target Example

Move Towards Target Example preview image

1 collaborator

Uri_dolphin3 Uri Wilensky (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 5.0.4 • Viewed 1204 times • Downloaded 71 times • Run 7 times
Download the 'Move Towards Target Example' 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

breed [people person]
people-own [target]

breed [houses house]

to setup
  clear-all
  set-default-shape houses "house"

  ;; CREATE-ORDERED- distributes the houses evenly
  create-ordered-houses number-of-houses
    [ fd max-pxcor ]

  create-people number-of-people [
    setxy random-xcor random-ycor
    set target one-of houses
    face target
  ]
  reset-ticks
end 

to go
  ask people [
    ;; if at target, choose a new random target
    if distance target = 0
      [ set target one-of houses
        face target ]
    ;; move towards target.  once the distance is less than 1,
    ;; use move-to to land exactly on the target.
    ifelse distance target < 1
      [ move-to target ]
      [ fd 1 ]
  ]
  tick
end 


; Public Domain:
; To the extent possible under law, Uri Wilensky has waived all
; copyright and related or neighboring rights to this model.

There are 8 versions of this model.

Uploaded by When Description Download
Uri Wilensky over 5 years ago Updated to NetLogo 5.0.4 Download this version
Uri Wilensky about 6 years ago Updated version tag Download this version
Uri Wilensky about 7 years ago Updated to NetLogo 5.0 Download this version
Uri Wilensky over 8 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 8 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 8 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 8 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 8 years ago Model from NetLogo distribution Download this version

Attached files

File Type Description Last updated
Move Towards Target Example.png preview Preview for 'Move Towards Target Example' almost 6 years ago, by Uri Wilensky Download

This model does not have any ancestors.

This model does not have any descendants.