[starlogo-users] RE: "min-of-turtles-with" question

Buck, Peter M peter.buck at eds.com
Wed Jun 30 09:49:45 EDT 2004


Sorry, original example has multiple mistakes.  What I meant to ask was,
instead of this

set distance-to-closest 99
dolist [ :candidate list-of-turtles-with [ color = green ] ]  [
	let [ :distance ( distance ( xcor-of :candidate ) ( ycor-of
:candidate ) ) ]
	if ( :distance < distance-to-closest ) [
		set distance-to-closest :distance
		set closest :candidate
	]
]


--is something like this possible?

set closest ( min-of-turtles-with [ color = green ] [ distance (xcor-of
:this-turtle) (ycor-of :this-turtle) ] )

That is, does min-of-turtles-with provide access to the who number of the
currently-considered turtle?

- Peter Buck


> _____________________________________________ 
> From: 	Buck, Peter M  
> Sent:	Wednesday, June 30, 2004 9:12 AM
> To:	'starlogo-users at media.mit.edu'
> Subject:	"min-of-turtles-with" question
> 
> I know I can find the nearest turtle with a certain attribute like this
> 
> set distance-to-closest 99
> dolist [:candidate list-of-turtles-with [color = green]] [
> 	let :distance [(distance (xcor-of :candidate) (ycor-of :candidate))]
> 	if (:distance < distance-to-closest) [set distance-to-closest
> :distance]
> ]
> 
> but it would be nice to be able to do it something like this
> 
> set distance-to-closest min-of-turtles-with [color = green] [distance
> (xcor-of :this-turtle) (ycor-of :this-turtle)]
> 
> What I've written would depend on variable :this-turtle being available in
> min-of-turtles-closest.  I haven't seen any suggestion that that is so.
> 
> Is what I am dreaming of possible?
> 
> Thanks,
> Peter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://education.mit.edu/pipermail/starlogo-users/attachments/20040630/590db73f/attachment.htm


More information about the starlogo-users mailing list