"Wave Collapse Function" algorithm in Processing

@jeremydouglass Thank you, really glad to hear your feedback !

Yes, I named the entropy array “H” by convention even though it is the entropy itself that should named “H”, not the array. Thinking about it now, “E” would be fine as well, at least it would ensure greater consistency between the arrays: W → wave, A → adjacency, E → entropy.

Totally agree. Thank you so much for your revised version. It’s beyond me why the annotated script doesn’t run on your side, it works perfectly fine on my computer…

@GoToLoop

In this regard I would also add that the overlapping model is more suitable for students, mainly for 3 reasons:

  • tilesets are not easy to get a hold of / create
  • it is easier to manage a single bitmap image than a whole set of tiles (no rotations to compute and store, no adjacencies or frequencies to enter by hand)
  • bitmap images can easily be created in Processing (downloading an example image is not mandatory)

Actually, the output that looks like an archipelago (first gif) was based on a input image made in Processing. Alternatively, this could be a great incentive for students / hobbysts to create their own bitmaps while learning the basics of Processing

Example

N = 16 # 16 x 16 pixels

def setup():
    size(N, N)
    
    # colors
    w = color(242, 242, 240) # white
    b = color(124, 215, 235) # blue
    g = color(66, 217, 134) # green
    B = color(0) # black
    c = color(198, 149, 99) # chestnut brown
    
    
    plant = [w, w, w, w, w, w, B, B, B, w, w, w, w, w, w, w,
             w, w, w, w, w, B, g, g, g, B, w, w, w, w, w, w,
             w, w, B, B, w, B, g, B, g, B, w, w, B, B, w, w,
             w, B, g, g, B, B, g, g, g, B, w, B, g, g, B, w,
             w, B, g, B, g, B, g, B, g, B, B, g, B, g, B, w,
             w, B, g, g, g, B, g, g, g, B, g, g, g, g, B, w,
             w, w, B, g, g, g, B, g, B, g, B, g, g, B, w, w,
             w, w, w, B, g, g, B, g, B, g, g, g, B, w, w, w,
             w, B, B, B, B, B, B, B, B, B, B, B, B, B, B, w,
             B, b, b, b, b, b, b, b, b, b, b, b, b, b, b, B,
             B, b, b, b, b, b, b, b, b, b, b, b, b, b, b, B,
             B, b, b, b, b, b, b, b, b, b, b, b, b, b, b, B,
             w, B, B, b, b, b, b, b, b, b, b, b, b, B, B, w,
             w, w, w, B, B, B, B, B, B, B, B, B, B, w, w, w,
             w, w, B, b, b, b, b, b, b, b, b, b, b, B, w, w,
             w, w, B, B, B, B, B, B, B, B, B, B, B, B, w, w]
    
    
    
    island = [b, b, b, b, b, b, b, b, b, b, b, b, b, b, b, b,
              b, b, b, b, b, b, b, b, b, b, g, g, b, b, b, b,
              b, b, b, b, b, b, b, b, g, g, g, g, g, b, b, b,
              b, b, b, b, b, b, b, b, g, g, g, g, g, g, b, b,
              b, b, b, b, b, g, g, g, g, g, g, g, g, g, b, b,
              b, b, b, b, g, g, g, g, g, g, g, g, g, g, b, b,
              b, b, g, g, g, g, g, g, g, g, g, g, g, g, g, b,
              b, b, g, g, g, g, g, g, g, g, g, g, g, g, g, b,
              b, b, c, g, g, g, g, g, g, g, g, g, g, g, g, b,
              b, b, b, c, g, g, g, g, g, g, g, g, g, g, c, b,
              b, b, b, b, g, g, g, g, g, g, g, g, c, c, b, b,
              b, b, b, g, g, g, g, g, g, g, g, g, b, b, b, b,
              b, b, b, c, g, g, c, c, g, g, g, g, b, b, b, b,
              b, b, b, b, c, c, b, b, c, c, c, c, b, b, b, b,
              b, b, b, b, b, b, b, b, b, b, b, b, b, b, b, b,
              b, b, b, b, b, b, b, b, b, b, b, b, b, b, b, b,]
    
    
    
    loadPixels()
    for i in xrange(width*height):
        pixels[i] = plant[i]
    updatePixels()
    
    
    save('C:\Path\to\Folder\name.png')

1 Like