diff --git a/CITATION.cff b/CITATION.cff index 29d253e..f2f3fd8 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -3,6 +3,7 @@ message: "Please cite if you use WFC in your research." authors: - family-names: Gumin given-names: Maxim + email: ExUtumno@gmail.com title: Wave Function Collapse Algorithm version: 1.0 date-released: 2016-09-30 diff --git a/Model.cs b/Model.cs index d513559..245a854 100644 --- a/Model.cs +++ b/Model.cs @@ -19,7 +19,6 @@ abstract class Model (int, int)[] stack; int stacksize, observedSoFar; - protected Random random; protected int MX, MY, T, N; protected bool periodic; @@ -82,14 +81,14 @@ public bool Run(int seed, int limit) if (wave == null) Init(); Clear(); - random = new Random(seed); + Random random = new Random(seed); for (int l = 0; l < limit || limit < 0; l++) { - int node = NextUnobservedNode(); + int node = NextUnobservedNode(random); if (node >= 0) { - Observe(node); + Observe(node, random); bool success = Propagate(); if (!success) return false; } @@ -103,7 +102,7 @@ public bool Run(int seed, int limit) return true; } - protected int NextUnobservedNode() + protected int NextUnobservedNode(Random random) { if (heuristic == Heuristic.Scanline) { @@ -139,7 +138,7 @@ protected int NextUnobservedNode() return argmin; } - void Observe(int node) + void Observe(int node, Random random) { bool[] w = wave[node]; for (int t = 0; t < T; t++) distribution[t] = w[t] ? weights[t] : 0.0; @@ -217,6 +216,7 @@ protected virtual void Clear() sumsOfWeights[i] = sumOfWeights; sumsOfWeightLogWeights[i] = sumOfWeightLogWeights; entropies[i] = startingEntropy; + observed[i] = -1; } observedSoFar = 0; } diff --git a/OverlappingModel.cs b/OverlappingModel.cs index f061eb3..7412296 100644 --- a/OverlappingModel.cs +++ b/OverlappingModel.cs @@ -154,7 +154,7 @@ public override Bitmap Graphics() Bitmap result = new Bitmap(MX, MY); int[] bitmapData = new int[result.Height * result.Width]; - if (NextUnobservedNode() < 0) + if (observed[0] >= 0) { for (int y = 0; y < MY; y++) { diff --git a/README.md b/README.md index 7f3c6f2..76103f9 100644 --- a/README.md +++ b/README.md @@ -104,7 +104,7 @@ One of the dimensions can be time. In particular, d-dimensional WFC captures the ## How to build WFC is a console application that depends only on the standard library. Get [.NET Core](https://www.microsoft.com/net/download) for Windows, Linux or macOS and run ``` -dotnet run WaveFunctionCollapse.csproj +dotnet run --configuration Release WaveFunctionCollapse.csproj ``` Alternatively, use build instructions from the community for various platforms from the [relevant issue](https://github.com/mxgmn/WaveFunctionCollapse/issues/3). Casey Marshall made a [pull request](https://github.com/mxgmn/WaveFunctionCollapse/pull/18) that makes using the program with the command line more convenient and includes snap packaging. @@ -178,6 +178,6 @@ that the resulting observed zone is navigable at each step. * DeepMind open-ended learning team [used](https://storage.googleapis.com/deepmind-media/papers/Open-Ended%20Learning%20Leads%20to%20Generally%20Capable%20Agents/open-ended-learning-paper.pdf) WFC to generate arenas for reinforcement learning agents. ## Credits -Some samples are taken from the games Ultima IV and [Dungeon Crawl Stone Soup](https://github.com/crawl/crawl). Circles tileset is taken from [Mario Klingemann](https://twitter.com/quasimondo/status/778196128957403136). FloorPlan tileset is taken from [Lingdong Huang](https://github.com/LingDong-/ndwfc). Idea of generating integrated circuits was suggested to me by [Moonasaur](https://twitter.com/Moonasaur/status/759890746350731264) and their style was taken from Zachtronics' [Ruckingenur II](http://www.zachtronics.com/ruckingenur-ii/). Cat overlapping sample is taken from the Nyan Cat video, Qud sample was made by Brian Bucklew, MagicOffice + Spirals samples - by rid5x, ColoredCity + Link + Link 2 + Mazelike + RedDot + SmileCity samples - by Arvi Teikari, Wall sample - by Arcaniax, NotKnot + Sand + Wrinkles samples - by Krystian Samp. Summer tileset was made by Hermann Hillmann. Voxel models were rendered in [MagicaVoxel](http://ephtracy.github.io/). +Circles tileset is taken from [Mario Klingemann](https://twitter.com/quasimondo/status/778196128957403136). FloorPlan tileset is taken from [Lingdong Huang](https://github.com/LingDong-/ndwfc). Summer tiles were drawn by Hermann Hillmann. Cat overlapping sample is taken from the Nyan Cat video, Water + Forest + Mountains samples are taken from Ultima IV, 3Bricks sample is taken from Dungeon Crawl Stone Soup, Qud sample was made by Brian Bucklew, MagicOffice + Spirals samples - by rid5x, ColoredCity + Link + Link 2 + Mazelike + RedDot + SmileCity samples - by Arvi Teikari, Wall sample - by Arcaniax, NotKnot + Sand + Wrinkles samples - by Krystian Samp, Circle sample - by Noah Buddy. The rest of the examples and tilesets were made by me. Idea of generating integrated circuits was suggested to me by [Moonasaur](https://twitter.com/Moonasaur/status/759890746350731264) and their style was taken from Zachtronics' [Ruckingenur II](http://www.zachtronics.com/ruckingenur-ii/). Voxel models were rendered in [MagicaVoxel](http://ephtracy.github.io/).