HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
mxgmn
WaveFunctionCollapse
C#2016–2026
mxgmn / WaveFunctionCollapse

WaveFunctionCollapse

Bitmap & tilemap generation from a single example with the help of ideas from quantum mechanics

55Distinct people
63Mentions
2Explicit recommenders
25.5KGitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

Bitmap & tilemap generation from a single example with the help of ideas from quantum mechanics

GitHub

Where it is used

No documented product use was verified in the last source check.

What people are saying

https://news.ycombinator.com/item?id=37485705 DonHopkins on Sept 12, 2023 | parent | context | favorite | on: CityDreamer: Compositional Generative Model of Unb... Here's some…

DonHopkins used a recommendation phrase. 3 indexed comments match. This is a phrase match, not a verdict.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

Mentioned in the same Hacker News threads. That is not proof they are substitutes.

This week on Hacker News

Nov 7–Nov 14 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/14/2026, 6:01:08 PM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by year63 dated mentions

Observed mentions: 2016-09-30 13:20:43 UTC to 2026-08-04 14:46:46 UTC.

0510152016-01-01 00:00:00 UTC to 2017-01-01 00:00:00 UTC (exclusive): 3 mentions; 1 submissions, 2 comments20162017-01-01 00:00:00 UTC to 2018-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2018-01-01 00:00:00 UTC to 2019-01-01 00:00:00 UTC (exclusive): 13 mentions; 1 submissions, 12 comments2019-01-01 00:00:00 UTC to 2020-01-01 00:00:00 UTC (exclusive): 6 mentions; 5 submissions, 1 comments2020-01-01 00:00:00 UTC to 2021-01-01 00:00:00 UTC (exclusive): 4 mentions; 1 submissions, 3 comments2021-01-01 00:00:00 UTC to 2022-01-01 00:00:00 UTC (exclusive): 6 mentions; 1 submissions, 5 comments20212022-01-01 00:00:00 UTC to 2023-01-01 00:00:00 UTC (exclusive): 10 mentions; 0 submissions, 10 comments2023-01-01 00:00:00 UTC to 2024-01-01 00:00:00 UTC (exclusive): 6 mentions; 1 submissions, 5 comments2024-01-01 00:00:00 UTC to 2025-01-01 00:00:00 UTC (exclusive): 3 mentions; 0 submissions, 3 comments2025-01-01 00:00:00 UTC to 2026-01-01 00:00:00 UTC (exclusive): 6 mentions; 0 submissions, 6 comments2026-01-01 00:00:00 UTC to 2027-01-01 00:00:00 UTC (exclusive): 5 mentions; 2 submissions, 3 comments. Incomplete calendar period.2026*

* An incomplete calendar period is marked with an outlined bar. Its count is not directly comparable with a full period.

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
20162016-01-01 00:00:00 UTC2017-01-01 00:00:00 UTC312
20172017-01-01 00:00:00 UTC2018-01-01 00:00:00 UTC101
20182018-01-01 00:00:00 UTC2019-01-01 00:00:00 UTC13112
20192019-01-01 00:00:00 UTC2020-01-01 00:00:00 UTC651
20202020-01-01 00:00:00 UTC2021-01-01 00:00:00 UTC413
20212021-01-01 00:00:00 UTC2022-01-01 00:00:00 UTC615
20222022-01-01 00:00:00 UTC2023-01-01 00:00:00 UTC10010
20232023-01-01 00:00:00 UTC2024-01-01 00:00:00 UTC615
20242024-01-01 00:00:00 UTC2025-01-01 00:00:00 UTC303
20252025-01-01 00:00:00 UTC2026-01-01 00:00:00 UTC606
2026 (partial)2026-01-01 00:00:00 UTC2027-01-01 00:00:00 UTC523

From the project README

An excerpt from the repository, fetched Nov 14, 2026.

Read the project’s introduction
WaveFunctionCollapse This program generates bitmaps that are locally similar to the input bitmap. Local similarity means that (C1) The output should contain only those NxN patterns of pixels that are present in the input. (Weak C2) Distribution of NxN patterns in the input should be similar to the distribution of NxN patterns over a sufficiently large number of outputs. In other words, probability to meet a particular pattern in the output should be close to the density of such patterns in the input. In the examples a typical value of N is 3. WFC initializes output bitmap in a completely unobserved state, where each pixel value is in superposition of colors of the input bitmap (so if the input was black & white then the unobserved states are shown in different shades of grey). The coefficients in these superpositions are real numbers, not complex numbers, so it doesn't do the actual quantum mechanics, but it was inspired by QM. Then the program goes into the observation-propagation cycle: On each observation step an NxN region is chosen among the unobserved which has the lowest Shannon entropy. This region's state then collapses into a definite state according to its coefficients and the distribution of NxN patterns in the input. On each propagation step new information gained from the collapse on the previous step propagates through the output. On each step the number of non-zero coefficients decreases and in the end we have a completely observed state, the wave function has collapsed. It may happen that during propagation all the coefficients for a certain pixel become zero. That means that the algorithm has run into a contradiction and can not continue. The problem of determining whether a certain bitmap allows other nontrivial bitmaps satisfying condition (C1) is NP-hard, so it's impossible to create a fast solution that always finishes. In practice, however, the algorithm runs into contradictions surprisingly rarely. Wave Function Collapse algorithm has been implemented in C++, Python, Kotlin, Rust, Julia, Go, Haxe, Java, Clojure, Free Pascal, Dart, p5js, JavaScript and adapted to Unity, Unreal Engine 5, Godot 4 and Houdini. You can build WFC from source, download an official release for Windows, download an interactive graphical version from itch.io or run it in the browser. WFC generates levels in Bad North, Caves of Qud, Dead Static Drive, Townscaper, Matrix Awakens, several smaller games and many prototypes. It led to new research. For more related work, explanations, interactive demos, guides, tutorials and examples see the ports, forks and spinoffs section. Watch a video demonstration of WFC algorithm on YouTube: https://youtu.be/DOQTr2Xmlz0 Algorithm Read the input bitmap and count NxN patterns. (optional) Augment pattern data with rotations and reflections. Create an array with the dimensions of the output (called "wave" in the source). Each element of this array represents a state of an NxN region in the output. A state of an NxN region is a superposition of NxN patterns of the input with boolean coefficients (so a state of a pixel in the output is a superposition of input colors with real coefficients). False coefficient means that the corresponding pattern is forbidden, true coefficient means that the corresponding pattern is not yet forbidden. Initialize the wave in the completely unobserved state, i.e. with all the boolean coefficients being true. Repeat the following steps: Observation: Find a wave element with the minimal nonzero entropy. If there is no such elements (if all elements have zero or undefined entropy) then break the cycle (4) and go to step (5). Collapse this element into a definite state according to its coefficients and the distribution of NxN patterns in the input. Propagation: propagate information gained on the previous observation step. By now all the wave elements are either in a completely observed state (all the coefficients except one being zero) or in the contradictory state (all the coefficients being zero). In the first case return the output. In the second case finish the work without returning anything. Tilemap generation The simplest nontrivial case of the algorithm is when NxN=1x2 (well, NxM). If we simplify it even further by storing not the probabilities of pairs of colors but the probabilities of colors themselves, we get what we call a "simple tiled model". The propagation phase in this model is just adjacency constraint propagation. It's convenient to initialize the simple tiled model with a list of tiles and their adjacency data (adjacency data can be viewed as a large set of very small samples) rather than a sample bitmap. Lists of all the possible pairs of adjacent tiles in practical tilesets can be quite long, so I implemented a symmetry system for tiles to shorten the enumeration. In this system each tile should be assigned with its symmetry type. Note that the tiles have the same symmetry type as their assigned letters (or, in other words, actions of the dihedral group D4 are isomorphic for tiles and their corresponding letters). With this system it's enough to enumerate pairs of adjacent tiles only up to symmetry, which makes lists of adjacencies for tilesets with many symmetrical tiles (even the summer tileset, despite drawings not being symmetrical the system considers such tiles to be symmetrical) several times shorter. Note that the unrestrained knot tileset (with all 5 tiles being allowed) is not interesting for WFC, because you can't run into a situation where you can't place a tile. We call tilesets with this property "easy". Without special heuristics easy tilesets don't produce interesting global arrangements, because correlations of tiles in easy tilesets quickly fall off with a distance. Many easy tilesets can be found on Guy Walker's website. Consider the "Dual" 2-edge tileset there. How can it generate knots (without t-junctions, not easy) while being easy? The answer is, it can onl
Read the full README on GitHub

What Hacker News says

10 sources
That's one of my long time interests and hobbies, which I write about on HN and discuss with other people frequently. I'm supposed to be doing something else right now so I'll quickly drop a few disorganized quotes and links here. (Sorry I didn't have time to be more concise!) A few years ago I ran across Max Bittker's beautiful "Sandspiel", which is a delightful cellular automata toy that simulates sand and other rules: https://sandspiel.club/ A few days ago I saw him tweet some amazing stuff that resonated with me, which then led me to discover what he's been working with Lu Wilson (TodePond): Sandspiel Studio -- user definable rules using a block based visual programming language. https://twitter.com/maxbittker "working on goth fungus kidpix": https://twitter.com/maxbittker/status/1593868837111451649 Lu Wilson (TodePond): https://twitt
Read the rest
er.com/TodePond Sandspiel Studio: https://studio.sandspiel.club/ Sandspiel introduction: https://www.youtube.com/watch?v=ecCVor7mJ6o Sandspiel Studio in 60 seconds: https://www.youtube.com/watch?v=qOA-lR3Xc34 Rainbow Sand: https://www.youtube.com/watch?v=PGTsy79wx4U Huegene: https://www.youtube.com/watch?v=ltpkO7jcFOY Flower: https://www.youtube.com/watch?v=ifyYITDq1oo TodePond's Spellular Automata: https://www.youtube.com/watch?v=xvlsJ3FqNYU We had a great discussion on the Sandspiel Studio Discord server, where I posted some interesting links: Check out the Long Now Foundation talk by Brian Eno and Will Wright about Generative Systems: 10:39 minute excerpt of Will talking about cellular automata and demonstrating with Mirak's Cellebration: https://www.youtube.com/watch?v=UqzVSvqXJYg 6:48 minute excerpt of Will demonstrating Spore Metaverses: https://www.youtube.com/watch?v=7t0kuvz5x_4 6:29 minute excerpt of Will demonstrating Spore Creature Demo: https://www.youtube.com/watch?v=8PXiNNXUUF8 Entire 1:38:50 hour Long Now Foundation talk: Playing with Time | Brian Eno and Will Wright https://www.youtube.com/watch?v=Dfc-DQorohc Craig Reynolds said the name "Boids" was inspired by The Producers Concierge scene, so that's how you should pronounce it: Boids. Dirty, disgusting, filthy, lice ridden Boids. Boids. You get my drift? https://www.youtube.com/watch?v=aL6mTMShVyk The other really cool rabbit hole to explore for generating tiles and even arbitrary graph based content (I'm sold: hexagons are the bestagons!) is "Wave Function Collapse", which doesn't actually have anything to do with quantum mechanics (it just sounds cool), but is actually a kind of constraint solver related to sudoku solvers. https://escholarship.org/content/qt3rm1w0mn/qt3rm1w0mn_noSpl... Maxim Gumin's work: https://github.com/mxgmn/WaveFunctionCollapse Paul Merrell's work: https://paulmerrell.org/model-synthesis/ https://paulmerrell.org/research/ Oskar Stålberg's work: https://twitter.com/OskSta/status/784847588893814785 https://oskarstalberg.com/game/wave/wave.html There's a way to define cellular automata rules by giving examples of the before and after patterns, and WFC is kind of like a statistical constraint solving version of that. So it's really easy for artists to define rules just by drawing! Not even requiring any visual programming, but you can layer visual programming on top of it. That's something that Alexander Repenning's "AgentSheets" supported (among other stuff): you could define cellular automata rules by before-and-after examples, wildcards and variables, and attach additional conditions and actions with a visual programming language. AgentSheets and other cool systems are described in this classic paper: “A Taxonomy of Simulation Software: A work in progress” from Learning Technology Review by Kurt Schmucker at Apple. It covered many of my favorite systems. http://donhopkins.com/home/documents/taxonomy.pdf Chaim Gingold wrote a comprehensive "Gadget Background Survey" at HARC, which includes AgentSheets, Alan Kay's favorites: Rockey’s Boots and Robot Odyssey, and Chaim's amazing SimCity Reverse Diagrams and lots of great stuff I’d never seen before: http://chaim.io/download/Gingold%20(2017)%20Gadget%20(1)%20S... Chaim Gingold has analyzed the SimCity (classic) code and visually documented how it works, in his beautiful "SimCity Reverse Diagrams": >SimCity reverse diagrams: Chaim Gingold (2016). >These reverse diagrams map and translate the rules of a complex simulation program into a form that is more easily digested, embedded, disseminated, and and discussed (Latour 1986). >The technique is inspired by the game designer Stone Librande’s one page game design documents (Librande 2010). If we merge the reverse diagram with an interactive approach—e.g. Bret Victor’s Nile Visualization (Victor 2013), such diagrams could be used generatively, to describe programs, and interactively, to allow rich introspection and manipulation of software. >Latour, Bruno (1986). “Visualization and cognition”. In: Knowledge and Society 6 (1986), pp. 1– 40. Librande, Stone (2010). “One-Page Designs”. Game Developers Conference. 2010. Victor, Bret (2013). “Media for Thinking the Unthinkable”. MIT Media Lab, Apr. 4, 2013. https://lively-web.org/users/Dan/uploads/SimCityReverseDiagr... Agentsheets: Alexander Repenning (1993–) Interacting agents are embedded and interact within cellular spaces called sheets. Agents are reactive to direct manipulation and have autonomous behavior. Agent Sheets draws upon a similarly spirited broad field of paradigms: artificial life, visual programming, “programmable drawing tools,” “simulation environments”, games, cellular automata, and “spreadsheet extensions.” Repenning draws upon these shared characteristics: visual, spatial notation, dynamic, direct manipulation, and incremental agency. The basic tool palette is also a gallery, defined in simulation terms. Highlights: • Kits (“agencies”) describe specific domains. One effect of “|ayered” design is “roles”—end-users vs. scenario designers. Example domains in thesis: Turing machines, circuits, flow, traffic, programs. • Sheet is a cellular 2d space, but agents can be stacked up in a cell. • Incremental refinement of art, behavior, etc… • A highly generalize idea of flow is used for things like neural nets, flow charts, water flow, circuits, system dynamic style models, and traffic. • It also supports ecological style spatial simulations. • User interaction and agent communication is in the same representation. i.e. Anything can do to one another everything the user can. AgentSheets is still going, and has even gone all 3D like Minecraft! AgentCubes! https://agentsheets.com/ Another great visual programming language for kids that supported defining cellular automata rules by example and visual programming: KidSim (later Cocoa, then Stagecast Creator) Smith, David C., Allen Cypher, and James Spohrer (1994) In KidSim graphical simulations are created via graphical rewrite rules, which also enables a kind of programming by demonstration. The creators argue that most people can use editor GUIs (e.g. paint programs), and can give directions, but cannot program. Their solution is to “get rid of the programming language” in favor of a philosophy grounded in GUI design: • Visibility. Relevant information is visible; causality is clear; modelessness. • Copy and modify, not make from scratch. • See and point, not remember and type. • Concrete, not abstract. • Familiar conceptual model. (“minimum translation distance”). They choose a symbolic simulation microworld as a domain because it leads to knowing, ownership, and motivation. All objects are agents which have appearances, properties (name value pairs), and rules. Programming by demonstration extends to using a calculator and dragging properties around to define conditionals. One of the creators of KidSim, David Smith, was also the creator of another graphical programming environment: Pygmalion. Smith, David C., Allen Cypher, and James Spohrer (1994) (Then I ran across TodePond's Spellular Automata video and realized I was preaching to the choir! TodePond wrote: "and stagecast creator is a big inspiration to me! I name-dropped it in a demo I did this week :D") Wow I did not realize I was evangelizing to the choir! This video by TodePond, is exactly what I was talking about, just much more beautiful than I'd imagined possible: https://www.youtube.com/watch?v=xvlsJ3FqNYU I was watching Lex Fredman interview Michael Levin, and Lex expressed the same level of fascination about cellular automata that I have: Michael Levin: Michael Levin: Biology, Life, Aliens, Evolution, Embryogenesis & Xenobots | Lex Fridman Podcast #325 https://www.youtube.com/watch?v=p3lsYlod5OU 1:44:29: Lex: Whenever I think about something like unconventional cognition, I think about cellular automata. I'm just captivated by the beauty of the thing. The fact that from simple little objects you can create such beautiful complexity that very quickly you forget about the individual objects and you see the things that it creates as its own organisms. That blows my mind every time. Like honestly I could full time just eat mushrooms and watch cellular automata. I don't even have to do mushrooms. Cellular automata, it feels like from the engineering perspective, I love when a very simple system captures something really powerful. Because then you can study that system to understand something fundamental about complexity, about life on earth. Anyway how Do I communicate with the thing? If a cellular automata can do cognition, if a plant can do cognition, if a xenobot can do cognition, how do I whisper in its ear and get an answer back, too? How do I have a conversation? How do I have a xenobot on the podcast? Then I watched Lex interview Steven Wolfram: https://www.youtube.com/watch?v=ez773teNFYA Stephen Wolfram: Cellular Automata, Computation, and Physics | Lex Fridman Podcast #89 - YouTube https://www.youtube.com I hate it when a program I wrote mocks me. In Lex Fridman's interview of Steven Wolfram, he demonstrates the machine learning functions in Mathematica by taking a photo of himself, which identifies him as a .... (I won't give it away): https://www.youtube.com/watch?v=ez773teNFYA&t=2h20m05s Here's a video I recently recorded of the CAM-6 simulator I implemented decades ago, and rewrote in JavaScript a few years ago. https://www.youtube.com/watch?v=LyLMHxRNuck I recorded that demo to show to Norman Margolus, who co-wrote the book and wrote the CAM6 PC Forth code and many rules, so it's pretty long and technical and starts out showing lots of code, but I'm sure you'll totally get and appreciate it. I linked to a pdf copy of the book in the comments, as well as the source code and playable app. Demo of Don Hopkins' CAM6 Cellular Automata Machine simulator. Live App: https://donhopkins.com/home/CAM6 Github Repo: https://github.com/SimHacker/CAM6/ Javacript Source Code: https://github.com/SimHacker/CAM6/blob/master/javascript/CAM... PDF of CAM6 Book: https://donhopkins.com/home/cam-book.pdf Comments from the code: // This code originally started life as a CAM6 simulator written in C // and Forth, based on the original CAM6 hardware and compatible with // the brilliant Forth software developed by Toffoli and Margolus. But // then it took on a life of its own (not to mention a lot of other CA // rules), and evolved into supporting many other cellular automata // rules and image processing effects. Eventually it was translated to // C++ and Python, and then more recently it has finally been // rewritten from the ground up in JavaScript. // The CAM6 hardware and Forth software for defining rules and // orchestrating simulations is thoroughly described in this wonderful // book by Tommaso Toffoli and Norman Margolus of MIT. // Cellular Automata Machines: A New Environment for Modeling // Published April 1987 by MIT Press. ISBN: 9780262200608. // http://mitpress.mit.edu/9780262526319/ Here's another demo I recorded a while ago that shows more rules: https://www.loom.com/share/cc09b916134b43cea201b61e71432f32 Making a Falling Sand Simulator: https://news.ycombinator.com/item?id=31309616 Oh My Gosh, It's Covered in Rule 30s: https://news.ycombinator.com/item?id=14458955 Wolfram Rule 30 Prizes: https://news.ycombinator.com/item?id=21130098 Finding Mona Lisa in the Game of Life: https://news.ycombinator.com/item?id=22552006 Andrew Wuensche's and Mike Lesser's gorgeous coffee table book, "The Global Dynamics of Cellular Automata": https://news.ycombinator.com/item?id=22570750 Here's some stuff about Dave Ackley's "Robust First Computing" and "Moveable Feast Machine": https://news.ycombinator.com/item?id=22304063 DonHopkins on Feb 11, 2020 | parent | context | favorite | on: Growing Neural Cellular Automata: A Differentiable... Also check out the "Moveable Feast Machine", Robust-first Computing, and this Distributed City Generation example: https://news.ycombinator.com/item?id=21858577 DonHopkins on Oct 26, 2017 | parent | favorite | on: Cryptography with Cellular Automata (1985) [pdf] A "Moveable Feast Machine" is a "Robust First" asynchronous distributed fault tolerant cellular-automata-like computer architecture. It's similar to a Cellular Automata, but it different in several important ways, for the sake of "Robust First Computing". These differences give some insight into what CA really are, and what their limitations are. Cellular Automata are synchronous and deterministic, and can only modify the current cell: all cells are evaluated at once (so the evaluation order doesn't matter), so it's necessary to double buffer the "before" and "after" cells, and the rule can only change the value of the current (center) cell. Moveable Feast Machines are like asynchronous non-deterministic cellular automata with large windows that can modify adjacent cells. Here's a great example with an amazing demo and explanation, and some stuff I posted about it earlier: https://news.ycombinator.com/item?id=14236973 Robust-first Computing: Distributed City Generation: https://www.youtube.com/watch?v=XkSXERxucPc https://news.ycombinator.com/item?id=22304110 DonHopkins on Feb 11, 2020 | parent | context | favorite | on: Growing Neural Cellular Automata: A Differentiable... Dave Ackley, who developed the Moveable Feast Machine, had some interesting thoughts about moving from 2D to 3D grids of cells: https://news.ycombinator.com/item?id=21131468 DonHopkins 4 months ago | parent | favorite | on: Wolfram Rule 30 Prizes Very beautiful and artistically rendered! Those would make great fireworks and weapons in Minecraft! From a different engineering perspective, Dave Ackley had some interesting things to say about the difficulties of going from 2D to 3D, which I quoted in an earlier discussion about visual programming: https://news.ycombinator.com/item?id=18497585 David Ackley, who developed the two-dimensional CA-like "Moveable Feast Machine" architecture for "Robust First Computing", touched on moving from 2D to 3D in his retirement talk: https://youtu.be/YtzKgTxtVH8?t=3780 "Well 3D is the number one question. And my answer is, depending on what mood I'm in, we need to crawl before we fly." "Or I say, I need to actually preserve one dimension to build the thing and fix it. Imagine if you had a three-dimensional computer, how you can actually fix something in the middle of it? It's going to be a bit of a challenge." "So fundamentally, I'm just keeping the third dimension in my back pocket, to do other engineering. I think it would be relatively easy to imaging taking a 2D model like this, and having a finite number of layers of it, sort of a 2.1D model, where there would be a little local communication up and down, and then it was indefinitely scalable in two dimensions." "And I think that might in fact be quite powerful. Beyond that you think about things like what about wrap-around torus connectivity rooowaaah, non-euclidian dwooraaah, aaah uuh, they say you can do that if you want, but you have to respect indefinite scalability. Our world is 3D, and you can make little tricks to make toruses embedded in a thing, but it has other consequences." Here's more stuff about the Moveable Feast Machine: https://news.ycombinator.com/item?id=15560845 https://news.ycombinator.com/item?id=14236973 The most amazing mind blowing demo is Robust-first Computing: Distributed City Generation: https://www.youtube.com/watch?v=XkSXERxucPc And a paper about how that works: https://www.cs.unm.edu/~ackley/papers/paper_tsmall1_11_24.pd... Plus there's a lot more here: https://movablefeastmachine.org/ Now he's working on a hardware implementation of indefinitely scalable robust first computing: https://www.youtube.com/channel/UC1M91QuLZfCzHjBMEKvIc-A John von Neumann's 29 State Cellular Automata https://news.ycombinator.com/item?id=22304084 John von Neumann's book "Theory of Self-Reproducing Automata": https://news.ycombinator.com/item?id=21858465 Factorio, and Will Wright on simulation games: https://news.ycombinator.com/item?id=24163024
In Ask HN: What weird technical scene are you fond/part of?
Hi! In my spare time, I’ve been making Crosswyrd, a web app for quickly and simply constructing, sharing, and playing dense New York Times-style crossword puzzles. The idea for the project came when I was dabbling in procedural generation recently and came across wave function collapse, which is a procedural generation algorithm inspired by quantum mechanics. To my knowledge wave function collapse hasn’t been applied to crossword puzzle generation before, so I was excited to explore how it fared in this context. The GitHub page (https://github.com/mxgmn/WaveFunctionCollapse) explains it well--in short, the algorithm starts with a blank canvas as an output, called a “wave,” where each tile is in some superposition of states; i.e., each tile could be any of the possible tiles. In the case of a crossword puzzle, each tile can be one of 26 le
Read the rest
tters. Then, the algorithm iteratively collapses each stretch of tiles into one of its possible words--and given the rules between the tiles (i.e., each intersecting stretch of tiles, "across" and "down," must be a word in a dictionary), propagates the resulting constraints across the rest of the board--until each tile has only one state. Each iteration, Crosswyrd’s algorithm collapses the “across” or “down” stretch of tiles with the lowest average Shannon entropy. If it finds a contradiction, it backs up and tries again with a different word. If all possible words at a given step are exhausted, it backs up to the previous level to try new words and so on. You can see this algorithm in action yourself using the Auto-Fill button. I’d recommend picking one of the preset 15x15 patterns and clicking Auto-Fill to see it go. The darker blue the tile, the lower the entropy for that tile. In practice, I am happy with how well and quickly the algorithm generates valid puzzles, and more importantly, I think it enables the app to push back some of the complexity of thinking about how words intersect to make space for more human creativity in constructing crossword puzzles. For example, by inspecting the state of the “wave,” it suggests words to the user that might work well in the selected slot, and it offers a word bank the user can fill out to click and drag their own words into valid slots in the puzzle. Of course, you can also just type words directly into the puzzle, and Crosswyrd will propagate the new constraints across the board as you go. A limitation of using wave function collapse for crossword constructing, as opposed to an algorithm that fully solves the puzzle, is that I can’t guarantee the user that the current puzzle state has a valid solution. For example, the user may place a word that the algorithm thinks is likely valid, only to find upon placing it that it causes a contradiction--this is because collapsing tile states causes constraints to cascade across the board, sometimes uncovering previously-unknown contradictions. However, I have some ideas for simple ways to mitigate this drawback, such as testing out the suggested words in the background as the user views them and updating the UI with the results of the tests as they come in. Feel free to play around with building your own puzzle, even publishing and sharing it! The crossword player I built adapts to both mobile and desktop screen sizes, so puzzles made in Crosswyrd should be playable on just about any device with a web browser and a screen.
In Show HN: A dense NYT-style crossword constructor using wave function collapse
This is phenomenal! I have been toying with similar ideas, and I am so glad you are the same person behind Wave Function Collapse [1] . The fact that you have lifted the technique into a programming language is immensely powerful. Where do you want to go with it? What research or other projects have been impactful on this work? From the author, 40 minutes of the algorithm running through examples. [2] Past stories about Wave Function Collapse [3] [1] https://github.com/mxgmn/WaveFunctionCollapse Youtube videos of WFC https://www.youtube.com/results?search_query=wave+function+c... [2] https://www.youtube.com/watch?v=DOQTr2Xmlz0 [3] https://hn.algolia.com/?dateRange=all&page=0&prefix=true&que...
In Show HN: MarkovJunior, PPL based on pattern matching and constraint propagation

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.