[starlogo-users] keeping track of myself
Andrew Begel
abegel at cs.berkeley.edu
Sat Jan 4 20:44:04 EST 2003
Your code is correct. Every command where you can ask another turtle
(or patch or observer) to perform an action will set myself to the
calling turtle's who. However, due to a ill-designed optimization for
those ask commands where one turtle/observer/patch was asking a single
turtle/observer/patch to do something, myself did not get set. We've
since fixed this, but haven't released the next version of StarLogo to
address it (we're waiting on fixing some more plotting problems).
As a really bad workaround, you could try this:
ask-turtles [if who = 0 [set myVariable myself]]
Sorry,
Andrew
On Saturday, January 4, 2003, at 03:25 PM, Brent Capps wrote:
> Which commands set the myself variable? I am trying to use ask-turtle
> to enable individual turtles to influence each other's behavior. The
> trouble is that ask-turtle doesn't seem to set the myself variable,
> which always seems to be -1. How can I copy the myVariable value for
> turtle 1 to turtle 0?
>
> Brent
> =======================
>
> OBSERVER CODE:
> to simInit
> clear-all
> create-turtles-and-do 2 [initTurtle]
> end
>
> TURTLE CODE:
> turtles-own [myVariable]
>
> to initTurtle
> ; Just to make sure the values are different
> if (who = 0) [set myVariable 4]
> if (who = 1) [set myVariable 6]
> end
>
> to copyTest
> if (who = 0) [
> ask-turtle 1 [
> type "myself is: "
> print myself
> set myVariable-of myself myVariable
> ]
> ]
> end
>
>
> OUTPUT WINDOW:
> Turtle #1: myself is: Turtle #1: -1
> -----
> Brent Capps
> Online Education Administrator
> Oregon Master of Software Engineering Program
> http://www.omseonline.org
>
> _______________________________________________
> starlogo-users mailing list
> starlogo-users at media.mit.edu
> http://education.mit.edu/mailman/listinfo/starlogo-users
More information about the starlogo-users
mailing list