[Squeakland] how to determine closest neighbor

Markus Gaelli gaelli at emergent.de
Mon Jan 12 20:13:25 PST 2004


Hi John,

if you didn't look for the nearest firefly but for the nearest post  
office ;-)
I would know an answer: Voronoi-diagrams.

From:  http://www.ics.uci.edu/~eppstein/gina/scot.drysdale.html

"Knuth's Post Office Problem -- Given a set of locations for post  
offices,
how do you determine the closest post office to a given house?
(Apparently, Knuth was ignoring the existence of ZIP codes.)

Closest Pair -- Given a set of points, which two are closest together?"

I also know, that there is a Voronoi-Implementation in Squeak, which is  
used
in Teddy / Alice- 3D-Worlds. It is hidden in the class category:  
Balloon3D-Pooh
So if you might give it a try.
In 3.7 the PoohTestMorph does not seem to work anymore, you should try  
with 3.4.
But it is Smalltalk. And I don't know how hard it would be to  
accommodate the code
for this question.
But I do know, that it would be great to have a field/instance variable  
for each player,
which would give its nearest neighbor, so I think it would be nice if  
you could leverage
that to Etoys

I did something in the same spirit some days ago.

There I leveraged "overlapping morph/player". Maybe giving them some  
kind of
almost (or total?) transparent surrounding and using the changeset  
below could
also do the trick for you.

I send the changeset to the dev-list, but did not get much reaction to  
the question
if it would be worth to include it. So I resend it here. It would be  
great if you would try it
and give some comments. See below.

Certainly "nearest neighbor" would be more general than "overlapping  
player",
so having a decent implementation of the first would make the second  
pointless.

Cheers,

Markus

> from preamble:
>
> "Change Set:		overlappingPlayer
> Date:			6 January 2004
> Author:			Markus Gaelli
>
> I showed a good friend of mine (a teacher) how to program space  
> invaders
> completely with Etoys.
> You can try out the result here:
>
> http://www.squeakland.org/project.jsp?http://www.emergent.de/pub/ 
> smallta
> lk/squeak/projects/petersInvaders.003.pr
>
> We used the common seesColor trick for the collision-detection, but we
> found it difficult to determine which UFO was hit by our laser, so I
> leveraged the existing Smalltalk Method called Morph >>
> morphsInFrontOverlapping:
>
> to a tile in miscellaneous called: overlappingPlayer in Etoys.
> Did we overlook some other way to find out with Etoys which of the UFOS
> have been hit by our shot?
>
> If not, should be put it to miscellaneous? Is it a problem that we only
> return one of
> possible many overlapped players? Is there a better name than
> overlappingPlayer?
> Should I send the changeset? Done... :-)
> "!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: overlappingPlayer.cs.gz
Type: application/x-gzip
Size: 1264 bytes
Desc: not available
Url : http://squeakland.org/pipermail/squeakland/attachments/20040112/328bc60e/overlappingPlayer.cs.bin
-------------- next part --------------
>
> In my paper and presentation text for the Squeak conference in Kyoto I
> made the mistake of mentioning syncing fireflies.  I feel that I can't 
> get
> away without presenting a working firefly simulation as part of the
> presentation.
>
> For the presentation, I am not so concerned that the fireflies behave
> exactly as they do in nature...only that they appear so. Nonetheless,
> faking it is only an option of last resort. The aspect of natural 
> behavior
> I am most concerned with simulating is that local behavior leads to 
> global
> behavior.
>
> In the paper, I claim that each firefly tracks the flash frequency of
> two nearby neighbors; it slows or accelerates its own frequency to
> match that of its neighbors until, thanks to the wonderful majic of
> network sync, the group of fireflies flash in unison.
>
> Most of this is pretty easy, but I can't, for the life of me, figure 
> out
> how to get each firefly to automatically determine its closest 
> neighbor.
>
> Any ideas?
>
> Thanks,
>
> John
>
> _______________________________________________
> Squeakland mailing list
> Squeakland at squeakland.org
> http://squeakland.org/mailman/listinfo/squeakland
>


More information about the Squeakland mailing list