Hi, Muaz!
I would probably implement the token itself as a breed of turtle, too.
The content of the token would be in a -own'd variable. Also, any
other token information, such as the source, destination, etc, can be
-own'd by the token turtle.
The turtles that are passing the token will then require a variable to
refer to the token, such as "token".
Then, creating a token is a matter of creating a new token turtle,
then setting the token variable of the node to the newly created token
turtle. A helper reporter can be used to make this easy and clear.
Passing the token then becomes a matter of one node setting the token
variable of a another node to its own token variable, before setting
the variable to nobody:
This is only one approach--you may desire or require a different one,
such as having nodes never set each others variables, but rather,
addressing tokens to each other, then picking up tokens addressed for
themselves.
Example breed definitions:
breed [ tokens a-token ]
tokens-own [ data source destination ]
breed [ nodes a-node ]
nodes-own [ token ]
to pass-to [ #node ]
;; Procedure to pass the token to a given node.
;; ... this is run by a node,
;; ... passes token to the given node
set [ token ] of #node token
;; ... clear own reference to the token
set token nobody
end
reporter used to to create a token:
to-report new-token [ #data #destination ]
;; assumes this is always run by a node (or other turtle)
let me nobody
hatch-tokens 1
[ set me self
set source myself
set destination #destination
set data #data
]
report me
end
usage of the reporter:
;; this is run by a node when it is ready to create a token
set token new-token some-data some-destination
Hope this helps,
~~James
_________________________
http://www.turtlezero.com
On 7/30/07, Muaz Niazi < thhgttg%40gmail.com">thhgttg
gmail.com> wrote:
> Hi,
>
> I have a breed of turtles, I want them to send a message to each other
> to implement a sort of token ring (The token is to be a data structure
> which expands over time). Any ideas how to do this data structure and
> message passing.
>
> Also, what kind of debugging can be done in NetLogo? Is it primarily
> print or show- based or is there any tool available for debugging (aka
> Watches/breakpoints etc.) 
>
>
> Take care,
>
> Muaz
.