mxgmn / WaveFunctionCollapse

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

No option for tile with no symmetry #36

Closed kjav closed 3 years ago

kjav commented 6 years ago

Hi,

I'm trying to add a tile to my tileset that does not have symmetry. Here is the tile:

diagonal2straight

I believe that this tile has none of the symmetry types (X, I, L, etc). Please correct me if I am wrong! However, I cannot seem to define this in the data.xml file; In fact, is it true that because of this line: https://github.com/mxgmn/WaveFunctionCollapse/blob/fad1066b5000f7e9fbda0ef81bbea56799686670/SimpleTiledModel.cs#L64 There is not currently an option for a tile with no symmetry? Thanks!

kjav commented 6 years ago

Here are some of the tiles that it is meant to connect to:

Tile images (click to view) ![bend](https://user-images.githubusercontent.com/9029686/39085002-0e38bf6e-4575-11e8-840d-858c855bde58.png) ![cross](https://user-images.githubusercontent.com/9029686/39085003-0e527f58-4575-11e8-8561-7ec272916633.png) ![diagonal](https://user-images.githubusercontent.com/9029686/39085004-0e68b6ce-4575-11e8-9a59-d8b788e2fd9c.png) ![diagonalbend](https://user-images.githubusercontent.com/9029686/39085005-0e83c752-4575-11e8-93cb-1282c3083b65.png) ![diagonalcap](https://user-images.githubusercontent.com/9029686/39085006-0e9ce96c-4575-11e8-82c1-a861520e02be.png) ![diagonalfork](https://user-images.githubusercontent.com/9029686/39085007-0eb2b8f0-4575-11e8-870f-27b53aaa85c6.png) ![diagonalhairpin](https://user-images.githubusercontent.com/9029686/39085008-0ec7d5be-4575-11e8-8d06-264c618d4021.png) ![empty](https://user-images.githubusercontent.com/9029686/39085009-0edb4a36-4575-11e8-9cb8-9a0223acc755.png) ![straight](https://user-images.githubusercontent.com/9029686/39085010-0ef31cba-4575-11e8-81cd-e216dddfe0d3.png) ![t](https://user-images.githubusercontent.com/9029686/39085011-0f096614-4575-11e8-918f-41d6e9894210.png)
mxgmn commented 6 years ago

Hi! You're right, there is indeed no option for a tile with no symmetry. I'll patch this up eventually, but I'm not sure when, it requires more than just adding else if (sym == 'J') { cardinality = 8; ...; }. I'm releasing a new version of WFC soon (as part of a larger project) with a different symmetry system that doesn't have this problem, because it induces the symmetry type from a low-pixel "scheme" of a tile.

kjav commented 6 years ago

Hi mxgmn,

Thanks for your reply - I'm glad I understood the problem correctly! Could you explain why adding a "cardinality = 8" option would not fully solve the problem? For instance, adding the following symmetry option does not solve the problem but I do not understand why:

cardinality = 8;
a = i => 0;
b = i => 0;
mxgmn commented 6 years ago

Because it currently assumes that all symmetries of the tile could be reached by rotating the base tile (which is not true for your example). And by setting i => 0 you are actually describing a maximally symmetric case. The right a action would look more like i => (i + 1) % 8.

shviller commented 6 years ago

I'm late to the party, but oh well, at least for posterity: the already mentioned fast-wfc has a symmetry="P" option, and additional indices for flipped+rotated tiles (4 for horizontally mirrored tile, for example)

zzz6519003 commented 5 years ago

how is this related to chaos theory? & hope for the demo!

chriskkkkl commented 4 years ago

Here is a solution: (1)Add the following lines to the list of symmetry operations/functions. else if (sym == 'F') { cardinality = 8; a = i => i < 4 ? (i + 1) % 4 : 4 + (i - 1) % 4; b = i => i < 4 ? i + 4 : i - 4; }

(2) Add reflection function after line 47 ("Color[] rotate(Color[] array) => tile((x, y) => array[tilesize - 1 - y + x tilesize]);"): Color[] reflect(Color[] array) => tile((x, y) => array[tilesize - 1 - x + y tilesize]);

(3) Change 135-136 ("tiles.Add(rotate(tiles[T + t - 1])); tilenames.Add($"{tilename} {t}");") as: if (t < 4) tiles.Add(rotate(tiles[T + t - 1])); if (t > 3) tiles.Add(reflect(tiles[T + t - 4])); tilenames.Add($"{tilename} {t}");

mxgmn commented 3 years ago

I tested @chriskkkkl's solution on the new tileset, it works.