TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Generating an infinite world with the Wave Function Collapse algorithm

278 点作者 klaussilveira4 个月前

17 条评论

mrtracy4 个月前
I work with this algorithm quite a bit in a personal project. (I&#x27;ve changed from calling it WFC to Model Synthesis; Paul Merrell earned the naming rights, unless we discover an even earlier description.)<p>I mentally divide it into two important components:<p>1. Cross-correlation (the &#x27;wave function&#x27;)<p>2. Label selection (choosing where the &#x27;collapse&#x27; occurs)<p>The &quot;cross-correlation&quot; is exactly what it sounds like - given an incomplete model and a set of example patterns, this data structure represents the cross-correlation of every place that any of the patterns would individually fit in the incomplete model. I think this is the most useful structure in the algorithm, and is a form of iterative &#x27;feature detection&#x27; over the incomplete model.<p>I think there are many interesting things which can be done with this which aren&#x27;t in the basic algorithm, such as:<p>- Having larger indivisible &#x27;patterns&#x27; and collapsing such patterns all at once. Although example patterns are always broken down into discrete cells, larger patterns can exist where each cell gets a unique label and very limited transition set. The cross-correlation will detect where they can be placed, and if one is chosen the entire pattern could be chosen at once.<p>- <i>Partial</i> seeding of labels, e.g. selecting portions of the incomplete model and artificially limiting the available labels in that area, without collapsing it.<p>- Addition of information to labels which aren&#x27;t easily expressed in an example pattern, such as rudimentary counting of distances.<p>The &#x27;label selection&#x27; portion (in WFC terms, this is the algorithm used to choose which space to &#x27;collapse&#x27;) is where <i>all</i> of the random generation comes into play. If using Model Synthesis for full world generation, <i>this</i> is what should be focused on for generating more interesting types of environments.<p>However, given the common label selection algorithms I&#x27;ve seen and used, I think that Model Synthesis excels mostly at adding small-scale, largely self-similar patterns onto constraints provided by a larger structure. I think that other proc-gen methods better lend themselves to generating large-scale structures. A combination of the two - generating a large-scale structure to serve as a constraint, and allowing model synthesis to fill in interesting detail - seems like a good path to explore.
评论 #42755430 未加载
评论 #42755578 未加载
评论 #42756781 未加载
jasonjmcghee4 个月前
I think proc gen like this often falls victim to the 1000 bowls of oatmeal problem.<p>Unless things _feel_ different, it just feels same-y.<p>Some games handle this well (often through biomes with different rules and&#x2F;or special areas with different rules) and others (interestingly, often those that talk about how many billions of possibilities there are) are techniquely different... But just all feel the same.<p>It&#x27;s interesting to see how game devs continue to be creative in this area and how many games continue to have this problem.
评论 #42751856 未加载
评论 #42752313 未加载
jerf4 个月前
People seem to go ga-ga over this algorithm with some frequency on HN, and I think it is only because of its in-name-only connection to quantum mechanics, because I have to say that as procedural generation algorithm I find it very lacking. It works on the cases I saw for something like a 10x10 grid decently enough but for any large-scale work it just produces endless seas of structureless repetition. Even the long-in-the-tooth &quot;just fire Perlin noise at varying levels of detail at the problem&quot; at least produces some overarching structure even if it is itself just random because the low-frequency, high-amplitude components you use will produce <i>some</i> sort of higher-level variation.<p>Literally <i>anything</i> with <i>any</i> hierarchy in it would be better, unless you&#x27;re really leaning into that SCP-esque, liminal-space creepiness. But if that isn&#x27;t your explicit goal I would definitely not recommend this for large-scale usage because in most projects that creepy liminal-space-ness is probably actively fighting your artistic goals.<p>It wouldn&#x27;t even take that much; lay down some sort of street network with some other algorithm, a bit of &quot;zoning&quot; to switch some tile sets between &quot;residential&quot; and some other zone or even just a couple different types of &quot;residental&quot;, perlin noise it up if you&#x27;ve got no better ideas, then use &quot;wave function collapse&quot; (I <i>really</i> dislike the in-name-only &quot;quantumness&quot; of the name, can hardly call the algorithm that with a straight face) to fill in the blocks. A straightforward implementation of that would still be pretty same-y but it would at least have <i>some</i> sort of structure.
评论 #42749213 未加载
评论 #42749605 未加载
评论 #42749575 未加载
评论 #42750013 未加载
评论 #42749675 未加载
评论 #42749892 未加载
atum474 个月前
First time I shared my version of the wfc algorithm I got a lot of shit also (echoing the theme of the comments). People did not like it at all that it was not about quantum physics.<p>Here&#x27;s mine if anyone is interested <a href="https:&#x2F;&#x2F;github.com&#x2F;victorqribeiro&#x2F;simpleWFC">https:&#x2F;&#x2F;github.com&#x2F;victorqribeiro&#x2F;simpleWFC</a>
评论 #42752698 未加载
Footnote73414 个月前
When did we start calling markov chains &#x27;wave function collapse&#x27;?
评论 #42749271 未加载
评论 #42749111 未加载
评论 #42749132 未加载
评论 #42749987 未加载
KronisLV4 个月前
&gt; The next challenge is to come up with interesting gameplay ideas for this project.<p>The idea of an infinite world, at least of buildings and such structures, very much reminds me of the Echo game: <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=i51x6-8GqkA" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=i51x6-8GqkA</a> or maybe the Blame! manga or the SCP fandom. It&#x27;s probably work pretty well for a horror&#x2F;survival game, or just something built around movement. There was also the Receiver game series, which used pre-built environment blocks that were randomly stitched together and it worked really well for that game.
评论 #42749507 未加载
Nihilartikel4 个月前
I feel like diffusion algorithms are going to make headway into the procedural generation space soon.<p>With WFC you can have your rules for how a city is credibly composed of certain tile selections at some scales. But I&#x27;m imagining a future where a game designer can prompt a diffusion model with something like &#x27;generate a mid size industrial city with a classy commercial district in the north and abandoned factories in the west, using the pre supplied positions of important buildings.&quot;<p>A diffusion model could be trained on the structure and semantics of a real city.
评论 #42749995 未加载
A_D_E_P_T4 个月前
That&#x27;s not &quot;infinite.&quot; It&#x27;s a <i>strictly</i> finite construct that can be forced to repeat itself an arbitrary number of times. The only interesting question is the size of the repeating block. (Presumably quite small.)<p>This is sort of analogous to the Library of Babel -- a fictional construct which contains every possible combination of Latin characters that fit in a 400-page book. The library has something like 26^1312000 books, but then inevitably must repeat. Its contents are either not infinite, or each volume it contains repeats itself infinitely many times.<p>Ramsey Theory describes this stuff, and it&#x27;s a useful thing to know, as it wards against sloppy use of &quot;infinite&quot; and &quot;finite.&quot;
tbalsam4 个月前
This is neat! However, it is now longer the WFC algorithm. The idea of the WFC algorithm is that it is limited to one-at-a-time iteration, this mathematically means that every element in the input communicates its full &quot;state&quot; to the output.<p>The parallel tiling is neat, and the resulting cross-boundary replacements are neat as well, but they are in no way WFC, and as a result will lack a lot of the positive properties of the original algorithm! This is a kind of procedural generation now that does approach the properties of WFC in the limit as the number of chunks and comparisons goes to infinity.<p>It is a great way to scale an approximate&#x2F;approximating WFC algorithm (and I&#x27;m a huge fan of the first post on this -- sent a video of results from it to someone just a month ago or so!), so it may end up being much more practical in use day-to-day due to the speed of chunk loading.<p>I do maintain that WFC looked a bit nicer and more natural due to the iterative collapse bit and the constraints out on it, it felt, very &quot;cohesive&quot;. I feel like some of that has been lost in the speedier chunk-based algorithm (i.e. the entropy of the generations is much lower), but, this doesn&#x27;t mean that it&#x27;s not as useful or anything like that. Just a tradeoff for parallel computation (and I&#x27;d call it something like &quot;approximate WFC&quot; or &quot;pre-baked approx WFC&quot; or the like just for clarity&#x27;s sake).<p>In any case, good work and I appreciate the problem solving skills and especially a lot of the hard problem solves like the heightmap differences and such. Very cool stuff and I&#x27;d love to see how this (and&#x2F;or adjacent techniques) get incorporated into games at some point in the future! :)
评论 #42756572 未加载
rbanffy4 个月前
&gt; The next challenge is to come up with interesting gameplay ideas for this project<p>Making it an open universe game would make sense.<p>Or a screen saver inspired on Apple’s Aerials. I’ve been wanting a No Man’s Sky one for my AppleTV since ever.
jebarker4 个月前
This is really interesting (to me who knows nothing about procedural generation). I keep thinking that game development (being the most obvious use case for this) is the ultimate playground for polymaths.
jb_briant4 个月前
I wanted to generate a procedural dungeon for a rogue like aspect of my game using WFC. It was a misunderstanding of what this very simplistic algo can do.<p>- it&#x27;s great to fill areas with kinda non repetitive patterns which feels random-ish<p>- it&#x27;s useless to build anything structured. Eg. You can&#x27;t guarantee that a path exists from the entrance of the dungeon and the exit&#x2F;goal.<p>I ended up doing it fully with traditional Procgen techniques, I&#x27;m easily at 100+ hours of work and it&#x27;s still only half of it.<p>Discussions about &quot;the problem of proc gen&quot; in games are missing the point. Procgen is a non-gameplay feature, and it&#x27;s very time consuming to get it right and controlled. The legend that you &quot;gain&quot; time is hilarious when you know how complicated things become with &quot;random generation&quot;.<p>Proc gen is a fantastic tool to bring diversity to non-interesting zones.<p>The game is in the point of interests, they host goals, challenges, (storyline), progression. All of that is directed by logic.
andsoitis4 个月前
Are these the foundations for us, one day, to procedurally generate an entire universe in which other conscious beings appear?
steveoscaro4 个月前
Someone smarter than me please tie this into the many worlds theory of the universe and collapsing wave functions.
tjpnz4 个月前
The universe is lazily evaluated.
评论 #42752534 未加载
DonHopkins4 个月前
<a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=37485705">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=37485705</a><p>DonHopkins on Sept 12, 2023 | parent | context | favorite | on: CityDreamer: Compositional Generative Model of Unb...<p>Here&#x27;s some comments and links about Wave Function Collapse I wrote recently:<p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=34561910">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=34561910</a><p>[...stuff about SandSpielStudio and block visual programming languages like Scratch and Snap!, Long Now talk between Will Wright and Brian Eno about Cellular Automata, etc ...]<p>The other really cool rabbit hole to explore for generating tiles and even arbitrary graph based content (I&#x27;m sold: hexagons are the bestagons!) is &quot;Wave Function Collapse&quot;, which doesn&#x27;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.<p><a href="https:&#x2F;&#x2F;escholarship.org&#x2F;content&#x2F;qt3rm1w0mn&#x2F;qt3rm1w0mn_noSplash_f68c38783c93e2a50047925fa9471286.pdf?t=qwgn02" rel="nofollow">https:&#x2F;&#x2F;escholarship.org&#x2F;content&#x2F;qt3rm1w0mn&#x2F;qt3rm1w0mn_noSpl...</a><p>Maxim Gumin&#x27;s work:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;mxgmn&#x2F;WaveFunctionCollapse">https:&#x2F;&#x2F;github.com&#x2F;mxgmn&#x2F;WaveFunctionCollapse</a><p>Paul Merrell&#x27;s work:<p><a href="https:&#x2F;&#x2F;paulmerrell.org&#x2F;model-synthesis&#x2F;" rel="nofollow">https:&#x2F;&#x2F;paulmerrell.org&#x2F;model-synthesis&#x2F;</a><p><a href="https:&#x2F;&#x2F;paulmerrell.org&#x2F;research&#x2F;" rel="nofollow">https:&#x2F;&#x2F;paulmerrell.org&#x2F;research&#x2F;</a><p>Oskar Stålberg&#x27;s work:<p><a href="https:&#x2F;&#x2F;twitter.com&#x2F;OskSta&#x2F;status&#x2F;784847588893814785" rel="nofollow">https:&#x2F;&#x2F;twitter.com&#x2F;OskSta&#x2F;status&#x2F;784847588893814785</a><p><a href="https:&#x2F;&#x2F;oskarstalberg.com&#x2F;game&#x2F;wave&#x2F;wave.html" rel="nofollow">https:&#x2F;&#x2F;oskarstalberg.com&#x2F;game&#x2F;wave&#x2F;wave.html</a><p>There&#x27;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.<p>So it&#x27;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.<p>That&#x27;s something that Alexander Repenning&#x27;s &quot;AgentSheets&quot; 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.<p>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.<p><a href="http:&#x2F;&#x2F;donhopkins.com&#x2F;home&#x2F;documents&#x2F;taxonomy.pdf" rel="nofollow">http:&#x2F;&#x2F;donhopkins.com&#x2F;home&#x2F;documents&#x2F;taxonomy.pdf</a><p>Chaim Gingold wrote a comprehensive &quot;Gadget Background Survey&quot; at HARC, which includes AgentSheets, Alan Kay&#x27;s favorites: Rockey’s Boots and Robot Odyssey, and Chaim&#x27;s amazing SimCity Reverse Diagrams and lots of great stuff I’d never seen before:<p><a href="http:&#x2F;&#x2F;chaim.io&#x2F;download&#x2F;Gingold%20(2017)%20Gadget%20(1)%20Survey.pdf" rel="nofollow">http:&#x2F;&#x2F;chaim.io&#x2F;download&#x2F;Gingold%20(2017)%20Gadget%20(1)%20S...</a><p>Chaim Gingold has analyzed the SimCity (classic) code and visually documented how it works, in his beautiful &quot;SimCity Reverse Diagrams&quot;:<p>&gt;SimCity reverse diagrams: Chaim Gingold (2016).<p>&gt;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).<p>&gt;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.<p>&gt;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.<p><a href="https:&#x2F;&#x2F;lively-web.org&#x2F;users&#x2F;Dan&#x2F;uploads&#x2F;SimCityReverseDiagr" rel="nofollow">https:&#x2F;&#x2F;lively-web.org&#x2F;users&#x2F;Dan&#x2F;uploads&#x2F;SimCityReverseDiagr</a><p>[... stuff about AgentSheets, KidSim, Lex Fridman interviews of Michael Levin and Steven Wolfram discussing Cellular Automata, CAM6 simulator, etc ...]<p>More:<p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=34561910">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=34561910</a>
评论 #42750987 未加载
flobosg4 个月前
(2023)