You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+52-1Lines changed: 52 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -26,6 +26,7 @@ Features:
26
26
What's not (yet) implemented:
27
27
- 3d map generation.
28
28
Generation of 3d maps (for `GridMap`s or multi-layered `TileMap`s) is not yet implemented.
29
+
- Wrapping.
29
30
- Tile probabilities.
30
31
It's currently not possible to control probabilities of certain tile types being "observed".
31
32
- Rules editor.
@@ -37,11 +38,61 @@ What's not (yet) implemented:
37
38
In cases when a cell can be rotated (`GridMap`), the algorithm treats each combination of tile type and rotation as a separate tile type.
38
39
So, you have to specify possible adjacent tiles for all rotations of each tile (in fact, just few are enough - the algorithm is able to infer other combinations automatically in most cases).
39
40
41
+
## How to use
42
+
43
+
### WFC2DGenerator node
44
+
45
+
The easiest way to use this addon to generate a map is by using a `WFC2DGenerator` node.
46
+
47
+
To do so follow the following steps:
48
+
49
+
1. Create (or use existing one) a tile set (if you're going to generate a 2d tile map) or mesh library (in case of a grid map).
50
+
2. Make a map (a TileMap or GridMap) with examples of how your tiles should be used.
51
+
3. Create a TileMap or GridMap generated map will be written to.
52
+
The new map should use the same tile set/mesh library as one created on step 2.
53
+
You may place some tiles on that map (eighter manually or procedurally), generator will take them into account and fill other cells accordingly.
54
+
But try to not create an unsolvable puzzle when doing so.
55
+
4. Create a `WFC2DGenerator` node and set the following properties:
56
+
-`target` should point to a map node that will contain a generated map - one created at step 3
57
+
-`positive_sample` should point to a node that contains an example of a valid map - created at step 2
58
+
-`rect` should contain a rect of target map that will be filled by generator
59
+
- there are some other settings that may influence behavior and performance of the generator, feel free to experiment with those after you have a basic setup running
60
+
5. Run the generator.
61
+
By default it will start as soon as a scene runs.
62
+
However, you can clear `start_on_ready` flag and call `start()` method on generator node manually.
63
+
For example, that can be useful if you fill some of cells in target map procedurally.
64
+
65
+
The resulting setup may look like the following:
66
+
67
+

68
+
69
+
Examples of such setups can be found in [examples](addons/wfc/examples) folder.
70
+
71
+
It may make sense to create and keep a minimal scene with generator, sample map and target map - just to ensure that samples are good enough to generate a good map with your tile set.
72
+
73
+
If some of tile combinations produced by generator don't look good - try adding a negative samples map and place tose combinations there.
74
+
75
+
### Advanced use
76
+
77
+
`WFC2DGenerator` node is a high-level convenient wrapper for lower-level components.
78
+
In some cases it may be useful to use the low-level components directly.
79
+
See [sudoku demo](addons/wfc/examples/demo_sudoku.tscn) as an example.
80
+
81
+
You can extend different classes of this addon to achieve a desired behavior different from what is available by default.
82
+
For example, you can:
83
+
- add support for different map types by implementing your own [`WFCMapper2D`](addons/wfc/problems/2d/mappers/mapper_2d.gd) subclass
84
+
- add support of global constraints by extending [`WFC2DProblem`](addons/wfc/problems/2d/problem_wfc_2d.gd)
85
+
- use your own versions of internal components with the same interface as `WFC2DGenerator` by creating your own subclass of `WFC2DGenerator`
86
+
87
+
There is no detailed documentation (at least, for now) on how to use or extend internal components of the addon.
88
+
So please refer to source code to find a way to do what you need and feel free to ask questions in [github issues](https://github.com/AlexeyBond/godot-constraint-solving/issues).
40
89
41
90
## Copyright notes
42
91
43
92
This addon is licenced under MIT licence.
44
93
45
-
Examples/demos use [assets](https://github.com/AlexeyBond/godot-constraint-solving/tree/master/addons/wfc/examples/assets) from [Kenney](https://kenney.nl/).
94
+
Examples/demos use [assets](addons/wfc/examples/assets) from [Kenney](https://kenney.nl/).
46
95
47
96
This addon uses [GUT](https://github.com/bitwes/Gut) for unit testing (not included in downloadable archive).
97
+
98
+
The [logo](./icon.png) is generated using Stable Diffusion.
0 commit comments