Ashfaq
Ashfaq

Reputation: 197

Keep track of visited patches in netlogo

How do i keep track of visited patches. A turtle is moving every where and i need to keep track of it that which patch is visited by a turtle or which is un-visited.

Upvotes: 1

Views: 1098

Answers (1)

Alan
Alan

Reputation: 9620

There are many ways to do this and their utility depends on your needs. Here is one way, using a list for memory. turtles-own [memory]

to setup
  ca
  crt 1 [set memory (list patch-here)]
end

to move  ;;turtle proc
  let unvisited patches with [not member? self [memory] of myself]
  move-to one-of unvisited
  set memory lput patch-here memory
end

In this simple example, the memory list grows without bound. In a real application, you probably will want to remove old memories after a certain length.

Upvotes: 2

Related Questions