mxgmn / WaveFunctionCollapse

Bitmap & tilemap generation from a single example with the help of ideas from quantum mechanics
Other
23.05k stars 1.23k forks source link

Reuse parts of outcome as constraints, and still obtain the same outcome? #66

Closed bitinn closed 4 years ago

bitinn commented 4 years ago
Screen Shot 2020-06-21 at 13 05 36 Screen Shot 2020-06-21 at 13 05 42

WFC allows us to set some initial constraints to limit outcomes.

One thing I would like to do, is to use parts of an outcome as constraint, then generate again.

The only problem is, given the same seed and parts of its outcome as constraints, I cannot obtain the same outcome again, because observation order is now different (initial entropy are different).

Can I satisfy this requirement without modifying WFC's underlying algorithm? I think I just need a smart way to do weighted randomization at observation step?

(This is assuming the random input is order-independent, for example, if we use a seeded hash function instead of random number generator.)

mxgmn commented 4 years ago

The only problem is, given the same seed and its outcome, I cannot obtain the same outcome again

Please help me understand your question. By seed you mean a PRNG seed or seed as the constrained part?

bitinn commented 4 years ago

The only problem is, given the same seed and its outcome, I cannot obtain the same outcome again

Please help me understand your question. By seed you mean a PRNG seed or seed as the constrained part?

The same seed here mean 2 things: (1) The PRNG seed we feed to the WFC run remains the same. (2) Since the constrained seed for each tile is derived from the PRNG seed and tile index, we can guarantee those seeds are order independent as well.

The problem is weight probability has changed due to constraint propagation. So we can no longer obtain the same tile observation result.

My StackOverflow question might be better phrased:

https://stackoverflow.com/questions/62490854/order-independent-weighted-random-selection

mxgmn commented 4 years ago

My StackOverflow question might be better phrased

I see. So you're trying to get the same result from 2 different constrained parts. Just interesting, why would you want to do this?

You can fix the order of observation. Or you can generate result from the first constraint, save this result, and use the choices from the save when generating from the second constraint.

bitinn commented 4 years ago

My StackOverflow question might be better phrased

I see. So you're trying to get the same result from 2 different constrained parts. Just interesting, why would you want to do this?

You can fix the order of observation. Or you can generate result from the first constraint, save this result, and use the choices from the save when generating from the second constraint.

Imagine this workflow: generate a texture, pick a part of it as constraint, use them to generate again.

Preferably, you want the 2nd result to remain the same, and then you change the seed to get different output.

But in reality the 2nd result won't match, because constraints reduce entropy, so we cannot obtain the same result even though we know it's one of possible solution.

So yeah, it looks like I need to save some more information.

mxgmn commented 4 years ago

Imagine this workflow: generate a texture, pick a part of it as constraint, use them to generate again. Preferably, you want the 2nd result to remain the same, and then you change the seed to get different output.

I see. Yeah, the simplest solution would be to just save the first result, or save the order of observation.