Wave Function Collapse library in pure C
github.com
github.com
- https://robertheaton.com/2018/12/17/wavefunction-collapse-al..., 44 comments https://news.ycombinator.com/item?id=18744696
- https://www.boristhebrave.com/2020/04/13/wave-function-colla..., 18 comments https://news.ycombinator.com/item?id=18321168
More threads: https://hn.algolia.com/?q=wave+function+collapse
https://marl0ny.github.io/QM-Simulator-2D/index.html
From the above link you can look single slit, double slit, triple slit, step, spike, or load an arbitrary image as a potential and do experiments in 2d box.
>This WebGL program simulates the quantum mechanics of a single particle confined in a 2D box, where inside this box the user can create new potential barriers and scatter Gaussian wavepackets off them. The full instructions are found here.
https://github.com/marl0ny/QM-Simulator-2D
btw. Wave function collapse in quantum physics is completely speculative phenomenon. There is only apparent wave function collapse.
To be more precise, the Born rule non-linear adjustment of the wave function to a single real value after a measurement is strictly necessary for QM to match experiments. Whether this should be interpreted as a physical phenomenon of wave function collapse, or as entanglement with the environment (MWI), or as an update of probabilities for hidden variables (Pilot wave) or some other phenomenon is speculative, but the wave function must be "collapsed" to a single real value after a measurement to correctly predict experimental results.
Wave-function collapse as a priori process is just speculation. Finding that it actually happens would be new physics.
Sure, in MWI the wave function of the universe never collapses, but something similar still happens for "parts" of the universal wave function.
The GPE models a condensate as a single-particle quantum wavefunction with a non-linear form of the Schrödinger Equation, so you get some interesting behaviour from the non-linearity while the simulation remains computationally feasible.
You can interact with the potential term by clicking and dragging inside the 2D box.
But it does seem appropriate to say they're variations of the same algorithm. As for the name, I don't like either: Wave Function Collapse is based on a silly pop-science interpretation of quantum mechanics, and Model Synthesis is extremely generic and forgettable. And it's not even a synthesis, more of a filtering process. I guess I'd stick with Wave Function Collapse.
[0] https://paulmerrell.org/wp-content/uploads/2021/07/compariso...
Oh well, I guess people like the fancy name.
The way "quantum leap" is used by laypeople springs to mind too; literally the opposite of what they mean (not only tiny but random).
also just reread your comment. I don't agree with the definition "small and random", it is smallest unit of measurement an arbitrary system magnitude can change
A quantum leap, on the other hand, happens when you are somewhere just sitting, and boom, now you're somewhere else. It just happened randomly, without any energy input from you. So to bring this back to the idiom, an example of a quantum leap would be this: "I had a dream yesterday that gave me the insight I needed to finish my proof of XYZ theorem!"
I don’t think what you’ve said is correct.
Random doesn't really enter into it. One can get that in a firmly non-quantized theory, as in one of Einstein's other 1905 papers, https://en.wikipedia.org/wiki/Brownian_motion#Einstein's_the... https://history.aip.org/exhibits/einstein/essay-brownian.htm https://physicsworld.com/a/einsteins-random-walk/
Strings have nothing to do with textiles. And, very confusingly, they aren't even related to fibers or threads. Zippers aren't related to textiles either.
Trees and bloom filters are not related to botany. Heaps and garbage collection are not about municipal waste management. Graph coloring, despite the term, has nothing to do with either pictures or pigments. Red-black trees aren't colored or botanical.
Bubble sort does not involve fluid dynamics. Neither does bucket or cocktail shaker sort for that matter.
Circular buffers are not round. You can't eat a spaghetti stack or poke your finger on a cactus stack.
int***** support;
see https://paulmerrell.org/wp-content/uploads/2021/07/compariso...
Pierre Terdiman from nvidia is doing some experiments using it, for Omniverse level generation:
https://twitter.com/PierreTerdiman/status/147663502794968678...
[1] https://paulmerrell.org/wp-content/uploads/2021/07/compariso...
I also tried generating some large images (like 1000x1000 pixels output, but small 64x64 input), but it only collapses around 100 cells/second, so this still takes about 3 hours assuming no contradictions are encountered.
Works well for small inputs and outputs though!
Having the code in the header gives a bit more flexibility considering the file layout. IMHO this is an awkward consequence of the missing de-facto-standard in C/C++ build systems.
I hate this idiom every time I come across it. I like to look at the header file to see the interface and important documentation, and this just obscures it. Depending on your compiler it can make debugging a huge pain as well.
I had no idea that cmake would do this, after reading quite a lot of things about cmake v.s. make and how to write various makefiles for them. I posit that the C build tools are fundamentally hard to comprehend.
Blindly trusting it will lead to the same outcome, regardless of the programming language ecosytem.
Besides that was just one example, there are plenty of them with turing complete languages.
If you embed the source in your project, the terribleness is about adding to your Makefile:
funkylib.o: funkylib.c
$(CC) $<
myfinalexe: ... funkylib.o ...
# your existing executable creation (linking) commandThis still works nicely: the important stuff (documentation and public interface) is at the top, followed by the 'unimportant' implementation at the botton of the file.
STB-style headers are a bit different from typical C++ 'single header libraries' in that they put the declaration and implementation into separate sections in the header file (with the implementation inside an #ifdef/#endif pair), while C++ headers are usually a wild mix of class declarations intermixed with implementation code in template and inline functions (which is indeed harder to read).
I don't quite understand how debugging is affected? E.g. there are (usually) no inline functions in STB-style headers.
Again, this is different from typical C++ single-header-libraries (e.g. pretty much all C++ stdlib headers) where the implementation code is inlined or in template code.
It's just easier to have a single .h you include.
No, it can be in a single place and you can just #include it.
>This .h will need to know if it got included multiple times, and so isn't just a trivial declaration.
This is the point of using header guards.
>It's just easier to have a single .h you include.
Depending on the build tool it's the same or only marginally easier (you save like 10 characters)
A hack designed by those that cannot be bothered to modularize a build with binary libraries.
The fact that one has to learn complex build tools (and often multiple ones), is the sad thing here. Luckily there are also unity builds, which are extremely handy in many contexts, because they are so fast and easy to use between different platforms without having to deal with annoying external tools.
All code that would otherwise live in .c files is between an #ifdef/#endif block which is only activated in a single compilation unit in the whole project.
Not sure how this approach would lead to redundant "function definitions" which would need to be deduped by the linker. The only overhead is in the preprocessor for skipping the implementation block, but that happens pretty much at IO speed - it's not comparable with the parsing overhead in typical C++ headers with template and inline code.
Still, it seems like an ugly kludge to cope with a breathtakingly antiquated way of doing things.
What ever happened to keeping it simple?
I think it's mainly a fix/workaround for the breathtakingly antiquated build systems in the C/C++ world ;)
In the end, STB-style single-header vs. a single .h/.c pair is not all that different, both are equally straightforward to integrate into a project.
The actual problem are libraries made of dozens/hundreds/thousands of header and source files and coming with their own complex build system setup.
By contrast, wfc is a breath of fresh air. The good stuff is in wfc.h, and the tool is in wfctool.c, which serves as an example for people who want to use the library. Consumers of the library have the option of writing a thin wrapper to produce an object file, or directly including it, if they prefer.
If this was a gargantuan library, it would make more sense to dicker about what's going into your build. But it's not a gargantuan library; it's tiny, and has the appropriate guard to prevent multiple compilations.
World.import(World.export(props))
Run that in an infinite loop.
Anyways this post ignited some deep contemplation