ndwfc icon indicating copy to clipboard operation
ndwfc copied to clipboard

Example Usage Not Working

Open SpicyMelonYT opened this issue 1 year ago • 0 comments

Not really sure what's going on here but the example code doesn't work for me.

I copied over the ndwfc.js file into my project EXACTLY. For brevity I am not going to paste that here. Also I am running it in a p5js project in the web editor. Here is my sketch.js file code:

function setup() {
  createCanvas(800, 800);

  nd = 2;
  weights = [1, 1, 1];
  rules = [
    ["x", 0, 1],
    ["x", 1, 0],
    ["y", 1, 2],
  ];

  wfc = new WFC({ nd, weights, rules });

  size = 5;
  wfc.expand([-size, -size], [size, size]);
}

function draw() {
  background(51);

  if (frameCount % 100 == 0) {
    var done = wfc.step();

    if (done) {
      size += 5;
      wfc.expand([-size, -size], [size, size]);
    }

    console.log(wfc.readout());
  }
}

When I run it it prints out this:

image

It seems like the issue is coming from the entropy or propogation part of the code as its running into NaNs. But I am confused why if the code I have is pretty much exactly the example code in the home page

SpicyMelonYT avatar Jan 25 '24 14:01 SpicyMelonYT