There is also another game/toy by Oskar Stålberg in which you can build a teeny, tiny block of house(s) on a 5x5 grid. Very cute, especially with all the well decorated balconies.
The house toy has a cute little easter egg: If you remove all the foundation pieces of the structure, the remaining structure above starts bobbing up and down slowly, hovering - very subtle way to acknowledge "yep, I did in fact think about that case too".
Huh. Adding one sea level block to the outside of that doughnut leads to all the propellers disappearing but no stilts. Resulting structure does not look very likely. :)
I highly recommend following indie devs on Twitter. It's always cool watching the game take shape over the years, and sometimes you also get behind-the-scenes details
Also wanted to pop in to recommend his Twitter. Watching these games get made has been a blast. Just the right mix of interesting math and creativity. I always dig into his blog posts and threads.
This uses the "wave function collapse" algorithm. Oskar Stalberg also made a great demo of how it works[0], but it might not make sense just from that. Martin Donald made a really nice youtube video on how it works[1]. The name "wave function collapse" can be off putting but it's pretty straightforward, and an algorithm that can come in handy for many uses both in game development and just general software development.
I'm actually procrastinating on HN from working on a GPU parallelised version that can generate millions of positions every frame. In Townscaper you can actually see that the algorithm runs quite slow and lags behind the players input, there's just a bunch of animation to hide it. I'm hoping to eventually get a version that can run in log2(mapsize) time.
I didn't know that constraint propagation existed. Having a quick look it does look the same.
In the in the original WFC(wave function collapse)[0] versions it always used an example of a completed output and generated all valid tile combinations from that. For a game this means that the developer can use hand made maps as examples for it to create new plausible maps. In the common vernacular WFC doesn't use this step and just directly either generates what combinations work or the devs manually decide what tiles can be next to others. Perhaps only the combination of both steps should be considered WFC.
Just to guess I think this is probably a case of it being developed independently in different fields. It's good to have another name for it as I always hated it being called "wave function collapse" when that is a physics thing.
The readme there refers to WFC as "constraint propagation with a saved stationary distribution" which makes sense; the goal is to have distributions of tiles similar to the sample image.
He designed it so you can fit a saved town in a tweet.
"It's my own very context specific implementation. I know how many bits I need for each bit of data, so I just store it all in a big bit array. I then convert that bit array to my own custom base 64 format, based on 64 web safe characters."
Worth reading the whole thread, as will all of Oskars twitter feed its super interesting.
The lookup key would be if the backend stores all the generated towns, and you're just referencing them. But I think simple encoding as you say is more probable
You have a fixed 3D grid, which appears to only need to store either a color or 'null' in every spot. You can encode this entire grid in any number of ways such that it creates a valid URL. Base64 most likely.
It takes about 90 seconds to load for me, but once it does, it's buttery smooth on my M1 Pro. Unity's web story is still so bad for many reasons, but the initial load times are a huge one (~15MB of wasm for an empty scene last I checked). They were working on Project Tiny[0] to address exactly this, but they've now paused work on it indefinitely :( Someone please build tools to fix this!
Its interesting in that perhaps if Unity gets it right it could fill the functional use case void that has been present ever since the demise of Adobe Flash - rich interactive user experiences within the browser.
And done natively with no need for the plugin mess and security holes of Flash. The key would be navigating the feature creep that led to the bulk and security holes of Flash.
Totally agree. Unity is definitely in the best position to become the new Flash, but so far, they seem completely uninterested in investing in that future. I can't totally blame them, because the vast majority of their revenue comes from mobile and their services business.
Unity already has the bulk, but the security holes shouldn't be as big of an issue given that it's "just a website" and runs in the browser sandbox.
> I can't totally blame them, because the vast majority of their revenue comes from mobile and their services business
Seems like they could make a whole new market though. It's more likely that browser support is being held back from Safari/Chrome to keep money flowing to app stores
PlayCanvas[0] is the probably the closest "web-first" solution compared to Unity. Used by lots of Snap Games & Instant Games. It's written in JS which means that it's way smaller ~350kB for an empty scene if I recall.
> It's written in JS which means that it's way smaller
There's nothing inherently large about WebAssembly, it's just that most practical wasm demos bundle emscripten (essentially an entire OS's standard library) or another very heavy layer in order to interop between the JS and WASM world.
As a bit of an experiment to see how small wasm could practically be with a minimal interop layer, I built this little project - the web demo is 90KB of JS + 70KB of wasm:
There's a lot of room for improvement in terms of size optimisation in most projects, but it's still early days and for now most of them just bundle an OS compatibility layer to get things working quickly.
I have a $300 laptop and a mobile (cell) Internet connection and it loaded quickly for me and is also butter-smooth. [Note: I also have 156 other tabs currently open in Chrome. And another 30 in Edge. Don't hate me!]
It's interesting I have a mid computer (3060/i9/80gb ram/ssd) and with gigabit fiber, it still takes a long time. What is taking a while? Maybe it's request load.
Once it loads though wow, the graphics are great, nice little physics effects. Wonder how many online games are like this. Light source/shadow also cool.
On subsequent loads it's fast like it's near 80-90% already.
You are in top 1% in RAM, top 2% in processor, and top 2% in GPU. I would not call that mid range. Hell I am running a 980Ti and its still on the top 10%.
It took 6 seconds for me (pretty similar computer and connection speed). I am however just 6 ms RTT away from its hosting location in Copenhagen, DK. (I'm in southern Sweden.)
Yes, but afaik, the experience of building for the browser as a runtime target for games in Godot is still not much better than Unity, just less bloated. I for one would love it if Godot made web a first-class focus, but it doesn't seem like they are yet.
Not sure why, but whenever I'm presented with something like this, I always seem to want to build the least functional, least utilitarian, most maddening and stupidest structure I can.
Full game doesn't crash, doesn't give you the browser scroll function on middle click (the shortcut to pick a color of an existing building), ability to export as STL, no full game links, ability to create oversized screenshots, some settings. The full game isn't deterministically equal to the browser one (roofs slope in different directions sometimes, decorations in different places). It should also run slightly better, although both are pretty lightweight.
Notably, the export strings are the same.
Basically: you're not missing anything from the core experience, but the browser version is slightly inferior. And buying the full version helps Oskar make more neat stuff in the future.
And here's another, slightly more technical talk from him about the "wave function collapse" algorithm he uses for procedural generation in his games: https://www.youtube.com/watch?v=0bcZb-SsnrA
I feel like this is how the UX for developing software should be. Types and intellisense plus copilot somewhat bring us close to something like this. Where adding a new module somehow automatically adjust itself to the project instead of having to provide strict API interfaces. Just a thought.
Hey, this sounds like the goal of the low code industry. To deliver an authoring experience where you don't have to worry about the semantics of code do develop software. It works really well in certain contexts, but a word of warning - there are trade offs. For instance, putting constraints on how applications talk to each other using APIs may seem limiting, but it does provide a standard interface that can be relied on for software to connect with one another.
Works great on my Android phone in Chrome. Oddly there's a message on startup saying WebGL won't work on mobile.
EDIT ah, it's unity's fault apparently. According to caniuse WebGL is golden for all mobile browsers. They should get with the times ;)
One thing that the demo could improve on in the mobile department is that scrolling is too sensitive. Most attempts at tapping to modify the structure result in a totally random change of the camera.
Yeah, this is super nice. I remember seeing all over twitter back then. At the time the articles were focusing on the wave function collapse, which I find awesome. Thank you for publishing it to the web so we could play with it.
The consistently beautiful looks comes from Oskar having handcrafted more than a hundred different puzzle piece models that together cover all the possible geometries. The models are not modified by the WFC algorithm, the algorithm just picks the right piece for every position. (However, the pieces, which are created square, are linearly deformed (skewed and scaled) to fit in the mostly non-square grid cells).
What determines which surfaces you can build on and which you can't? It seems random — I can keep clicking on an end wall to extend the building for a while, and then suddenly I can't anymore.
Safari is pretty behind the times as browsers go, especially with WebGL. For instance, it doesn't support WebGL 2 (except maybe in beta?), which means you have to use WebGL 1. I'm guessing that's where some of the performance issues would come from.
> I'm not a casual gamer so I think it's too simple.
I think it's not really a game and maybe calling it that sets unrealistic expectations. A toy? An experience?
I love things like this and wish there were more. I'm not a casual gamer and I'm not often a non-casual gamer (long periods of addiction to Minecraft, Skyrim and a few others not withstanding)
Maybe it's why I love PC VR which many "true gamers" complain is lacking in games. It's full of crazy, weird stuff and I love it.
Part of the fun for me is that it's kind of like a zen garden, but for buildings. I would love to see people start to populate and let the computer decide what they do and what the buildings are used for based on conditions created by the design of the city.
This is a bit like saying that AoE is cool but could do with some lasers. Townscaper is v well established and has found quite a niche and fandom for itself.
https://oskarstalberg.com/game/house/index.html
The author is on Twitter and sometimes tweets about development of his games and the techniques involved.
https://twitter.com/OskSta