Agent goal-list demo

Agent goal-list demo preview image

1 collaborator

Ahdekker Anthony Dekker (Author)



Tagged by Anthony Dekker over 10 years ago


Tagged by Anthony Dekker over 10 years ago


Tagged by Anthony Dekker over 10 years ago

Visible to everyone | Changeable by the author
Model was written in NetLogo 5.0.3 • Viewed 899 times • Downloaded 66 times • Run 0 times
Download the 'Agent goal-list demo' modelDownload this modelEmbed this model

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


This example is explained in the tutorial at


Click SETUP to start. Clicking GO makes each agent execute this list of four goals:

[ "goto" 3 3 "meet" 7 "scatter" "meet" 0 ]

Use NEW-GOAL and ADD-GOALS to add entries on the end of the goal lists.

Comments and Questions


This model is associated with a tutorial at

Posted over 10 years ago

new model , want suggestion and guidance

I want to create a model in which there are two populations of customers and providers. customers can request for service and provider fulfill it by accepting request.

Posted over 10 years ago


Sana, I would tackle that with a global list of requests, which customers add to, and providers fulfil. The requests themselves can be lists, containing relevant details, including references to the customer agent, if needed.

Posted over 10 years ago

Click to Run Model

turtles-own [
  id     ;; agent id number or name (usually a copy of "who")
  speed  ;; agent speed in cells per tick
  goal   ;; goal list

to setup
  crt 20 [ setxy random-xcor random-ycor
    set speed (0.1 + (random-float (max-agent-speed - 0.1)))
    set size 3
    set id who
    set goal [ "goto" 3 3 "meet" 7 "scatter" "meet" 0 ]
    set label id ]

to add-goals
  ask turtles [
    set goal (sentence goal (read-from-string new-goal))
    if (verbose) [ show (fput "goal =" goal) ]

;; NetLogo code for obeying instructions ;;

to obey
  if (goal != []) [
    let kind (item 0 goal)
    if-else (kind = "goto") [ if (obey-goto (item 1 goal) (item 2 goal)) [ drop3-goal ] ] [
    if-else (kind = "meet") [ if (obey-meet (item 1 goal)) [ drop2-goal ] ] [
    if-else (kind = "scatter") [ obey-scatter ] [
    obey-unknown kind ] ] ] ]

to drop-goal
  set goal (bf goal)

to drop2-goal
  set goal (bf (bf goal))

to drop3-goal
  set goal (bf (bf (bf goal)))

to obey-unknown [ g ]
  show (list "unknown goal" g)

to obey-scatter
  let new-x random-xcor
  let new-y random-ycor
  if (verbose) [ show (list "scattering to" new-x new-y) ]
  set goal (sentence (list "goto" new-x new-y) (bf goal))

to-report obey-goto [ x y ]  ;; obey "goto x y" command; report true when achieved
  let d (distancexy x y)
  if-else (d = 0)
    [ if (verbose) [ show (list "already at" x y) ]
      report true ]
    [ facexy x y
      if-else (d <= speed)
        [ setxy x y
          if (verbose) [ show (list "have reached" x y) ]
          report true ]
        [ fd speed
          report false ] ]

to-report obey-meet [ ag-id ]  ;; obey "meet agent" command; report true when achieved
  let him (one-of (turtles with [ id = ag-id ]))
  if-else (him = self)
    [ if (verbose) [ show (list "i am" him) ]
      report true ]
    [ face him
      let d (distance him)
      if-else (d <= speed)
        [ move-to him
          if (verbose) [ show (list "have met" him) ]
          report true ]
        [ fd speed
          report false ] ]

to go
  if (count (turtles with [ goal != []]) = 0) [ stop ]
  ask turtles [ obey ]

There is only one version of this model, created over 10 years ago by Anthony Dekker.

Attached files

File Type Description Last updated
Agent goal-list demo.png preview Preview for 'Agent goal-list demo' over 10 years ago, by Anthony Dekker Download

This model does not have any ancestors.

This model does not have any descendants.