-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Docs] Custom Preconditions2D #16
Comments
Hi.
You may think of it as of a fancy but limited and inconvenient array. In context of preconditions, it is used to return (from The minimal set of operations you will have to use is creating a bit set and adding a value to it. The bit set is created as by calling a constructor: var mybitset = WFCBitSet.new(size); where A value is added to a set by calling mybitset.set_bit(2) These two operations may be enough for basic precondition implementation (just create a bit set and add some tile ids to it). But other methods may be useful as well.
The mapper is responsible for interaction between WFC generator and a map node. There are different mapper subclasses that work with different map nodes ( They map data between formats specific for map types and unified representation used by WFC generator and related stuff, including preconditions. In precondition mapper is used to get data about available tile types:
The number of tiles is returned by There are two approaches to provide tile categories data to the precondition:
Tile metadata is accessed using For example, if you want to mark some tiles as tiles belonging to "forest" area, you may create a "is_forest" boolean data layer in the tileset and then use the following code to create a set of all tiles that have this data layer set to var forest_domain = WFCBitSet.new(mapper.size());
for i in range(mapper.size()):
if mapper.read_tile_meta_boolean(i, "is_forest"):
forest_domain.set_bit(i) In dungeon precondition this approach is implemented in This approach is extremally convenient with In case of In this case to configure a precondition a separate map is created. And reference to that map stored in your precondition settings object (see below). In dungeon precondition this is implemented in Dungeon precondition demos show most of configuration variants - tilemap with metadata, gridmap with metadata and gridmap with auxiliary map.
To use a custom precondition with
|
Thank you! This clears up a lot of questions I had reading the code! I will let you know if I have more problems worth documenting. |
Hello,
I want to preface with how much I appreciate this addon as it offers a very complete and relatively easy to use integration of WFC. I am trying to make a custom Precondition2D that uses perlin noise (Or simplex noise) to create denser forested areas and plains that are to be populated by WFC. However, I am having trouble understanding how to use the bitset object and the mapper object. I'm also uncertain on how to add the custom precondition to the generator. Would it be possible to have a small crash course? The dungeon example isn't super explanatory...
The text was updated successfully, but these errors were encountered: