AlexeyBond / godot-constraint-solving

WFC (Wave Function Collapse) and generic constraint satisfaction problem solver implementation for Godot 4
https://godotengine.org/asset-library/asset/1951
MIT License
357 stars 14 forks source link

Does this respect the various properties of the tile? #12

Closed feelingsonice closed 8 months ago

feelingsonice commented 10 months ago

First of all, this is an awesome plugin. I apologize for making an issue post as there's no discussion post options. This is not an issue, just a question. Does this plugin respect the various properties painted onto the tile? e.g. custom data, physics, navigation, etc?

AlexeyBond commented 10 months ago

Hi.

This addon uses some properties of tiles:

In other cases it works with just a tile identifier (atlas id, coordinates within atlas, alternative tile id). It reads these identifiers from sample map and writes them to target map. Additional tile data (custom data layers, physics, navigation, etc) is associated with this identifier (i.e. it's a property of tile in tileset, not of a cell in tilemap), so it will be present in generated map. Tile properties do not influence what tile combinations are allowed in generated map - that is determined by rules inferred from sample map(s) only.

I hope, this answers your question.

I apologize for making an issue post as there's no discussion post options. This is not an issue, just a question.

I guess, that's the right way to ask questions, since discussions are not enabled. Not sure if it makes sense to enable them yet.

feelingsonice commented 10 months ago

Additional tile data (custom data layers, physics, navigation, etc) is associated with this identifier (i.e. it's a property of tile in tileset, not of a cell in tilemap), so it will be present in generated map.

So it does preserve those tile data but does not use it to generate the rules. Am I stating that correctly?

Another question I have is about layers. Does the rule generator take layers into account? e.g. tile_A in layer_1 is on top of tile_B in layer_2?

feelingsonice commented 10 months ago

Another question I have is about layers. Does the rule generator take layers into account? e.g. tile_A in layer_1 is on top of tile_B in layer_2?

I guess another way to phrase is, does it consider the combination of layers on a single cell (e.g. tile_A + tile_B) a single domain, or does it do something else with layered information?

AlexeyBond commented 10 months ago

So it does preserve those tile data but does not use it to generate the rules. Am I stating that correctly?

Technically, probabilities are a part of rules. But in general - yes none of tile data is used to generate list of allowed tile combinations.

Does the rule generator take layers into account? e.g. tile_A in layer_1 is on top of tile_B in layer_2?

When a tilemap has multiple layers, each combination of tiles in a cell is considered as a separate tile. E.g. "tile A on layer 0 and tile B on layer 1" is considered as single tile. Note that "no tile on layer 0 and tile A on layer 1" and "tile A on layer 0 and no tile on layer 1" are considered as different tiles.

I guess another way to phrase is, does it consider the combination of layers on a single cell (e.g. tile_A + tile_B) a single domain

That wouldn't be a correct question. Domain is a set of values a variable may have. In case of WFC on tilemaps - a set of tiles certain cell of tilemap may contain. So "tile_A + tile_B" (or rather "tile A on layer 0 and tile B on layer 1") is one value that may be contained in domains of some tilemap cells.

feelingsonice commented 10 months ago

@AlexeyBond this is amazing. Do you plan on supporting other algorithms? e.g. perlin noise to precondition the terrain?

AlexeyBond commented 10 months ago

Do you plan on supporting other algorithms? e.g. perlin noise to precondition the terrain?

Yes, I do have plans to make some noise-based preconditions for things like terrain/biomes. Dungeon generator needs some improvements as well - to support hexagonal maps, tilesets where tileas are not "passable" in all directions, start point customization, etc.

It would also be nice to have a way to ingegrate other independent procedural generation plugins as preconditions for WFC, but I don't yet see how it could be done.

If you have any suggestions on what else can be added - feel free to leave them here (or implement them yourself and create a PR).

feelingsonice commented 10 months ago

btw, is this using ac3 or ac4?

AlexeyBond commented 10 months ago

It's AC3.

feelingsonice commented 10 months ago

What about scene collections? Does it support scenes as tiles or only atlas?

AlexeyBond commented 10 months ago

What about scene collections? Does it support scenes as tiles or only atlas?

I didn't test it before. Just added some scene collections to example scenes and it seems to work fine (particles above some tiles are a scene from tileset): image