123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|679|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> Cobra -> Contiguity algorithm?

Sun, 23 May 2010, 14:34
HoboBen
I've got this simple loop that attempts to identify contiguous terrain, like so: (left - terrain, right - identified contiguous groups)


(Each contiguous group is given its own colour)

While it's probably "good enough", it's not 100%, as you can see parts of the ocean are shown as different colours.

Does anyone know the name of an algorithm or method that would provide the best results? Ideally without being too exponentially slow.

The code:



-=-=-
blog | work | code | more code
Sun, 23 May 2010, 15:01
Jayenkai
Whenever I'm doing "Blocks vanish when alike colours meet" I tend to filter through a few times..
x=1->max, y=1->max
then y=max->1, x=max->1
then again x=max->1, y=1->max

The first time, you do the whole thing, then the second and third, check for "if same color as, and should be same group, but isn't!" and replace where necessary.

-=-=-
''Load, Next List!''
Sun, 23 May 2010, 15:11
HoboBen
Thanks Jay! Merging the groups worked great. This horrible beast of a loop did the trick:



-=-=-
blog | work | code | more code