BorisTheBrave / DeBroglie

DeBroglie is a C# library implementing the Wave Function Collapse algorithm with support for additional non-local constraints, and other useful features.
https://boristhebrave.github.io/DeBroglie/
MIT License
471 stars 37 forks source link

"Pinning" and filling around existing content? #3

Open justonia opened 6 years ago

justonia commented 6 years ago

In this example I have created a custom constraint that uses Select() to "pin" areas (cyan regions) of my output such that it has to be present in its exact configuration in another generation:

image

Cyan regions remain in new output:

image

This works fine, because each cyan region contains tiles that do not contradict with the rules of the input model. However if I attempt to pin a region that does not follow the rules on its interior:

image

I get an immediate contradiction after the Select call since the pinned region has water tiles next to water tiles and that is not defined in the input model.

If I wanted to make this work I could of course add water next to water in my model. The downside is that now my output will contain lakes. I see two potential options as an enhancement that might allow for this:

Do any of these sound like reasonable solutions?

BorisTheBrave commented 6 years ago

You can add some lake samples, then call MultiplyFrequency to set the frequency of the the lake tile to zero. Then it is legal to place, but WCF will never choose to place it (unless it is the only legal placement). In your case, you still want rivers to be placed, so you'll want two different tiles, one for lakes and one for rivers.

I'll have a think about if there's a neater way to do things like this. Perhaps an option on Select that lets you ignore compatibility?

justonia commented 6 years ago

I'll give MultiplyFrequency a shot with some special tiles. Being able to force Select into setting a tile might be a good quick way to accomplish this. Combined with #2, you'd end up having a lot of new controls on how content gets generated.

BorisTheBrave commented 6 years ago

Ok, I've had a thought about what you want. I think you won't find adding holes alone sufficient. Holes would be totally ignored, you want a tile to influence other tiles, but not be influenced itself. I think it'll be possible to set up another bit field for that behaviour.