Skip to content

Commit 1e1213e

Browse files
committed
Update README; random changes in scenes/resources
1 parent 726839f commit 1e1213e

File tree

6 files changed

+745
-24
lines changed

6 files changed

+745
-24
lines changed

README.md

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Features:
2626
What's not (yet) implemented:
2727
- 3d map generation.
2828
Generation of 3d maps (for `GridMap`s or multi-layered `TileMap`s) is not yet implemented.
29+
- Wrapping.
2930
- Tile probabilities.
3031
It's currently not possible to control probabilities of certain tile types being "observed".
3132
- Rules editor.
@@ -37,11 +38,61 @@ What's not (yet) implemented:
3738
In cases when a cell can be rotated (`GridMap`), the algorithm treats each combination of tile type and rotation as a separate tile type.
3839
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).
3940

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+
![Example of WFC2DGenerator setup](screenshots/example-01.png)
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).
4089

4190
## Copyright notes
4291

4392
This addon is licenced under MIT licence.
4493

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/).
4695

4796
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.
Binary file not shown.

addons/wfc/examples/demo_wfc_2d_gridmap.tscn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ data = {
6565
metadata/_editor_floor_ = Vector3(0, 0, 0)
6666
6767
[node name="target" type="GridMap" parent="."]
68+
visible = false
6869
mesh_library = ExtResource("1_in0m7")
6970
cell_size = Vector3(1, 1, 1)
7071
data = {

0 commit comments

Comments
 (0)