O
Oskar Stålberg
oskarstalberg.com · Personal blog · on HN since 2015
Portfolio of game developer Oskar Stålberg, with browser demos of procedural generation, wave function collapse, and his game Townscaper.
What HN saysCommenters enjoy Townscaper as a relaxing toy and link his demos as clear examples of wave function collapse and WebGL work.
44HN people shared it
28linked it in comments
17stories submitted
927story points
1 year agolast shared
2015people per year2026
Most-shared posts
- 1Townscaper Running in the Browser17 people · 703 points · first shared 2021 · 97 comments on HN
- 2Brick Block (2016)9 people · 207 points · first shared 2017 · 36 comments on HN
- 3Polygonal Planet Project8 people · 11 points · first shared 2016 · 1 comments on HN
- 4Wave Function Collapse Demo5 people · 2 points · first shared 2018 · discussion on HN
- 5CityGenerator3 people · first shared 2017
- 6Procedurally-Generated Art by Oskar Stålberg1 people · 3 points · first shared 2015 · discussion on HN
- 73D In-Browser Tile Editor1 people · 1 points · first shared 2015 · discussion on HN
- 85b6b4a87 7358 438a a06d fd708250936b(1)1 people · first shared 2021
- 9UnityLoader.js(1)1 people · first shared 2021
What HN people wrote when they linked it
samwillis · 2022-06-19
Townscaper is an amazing little toy, my kids (and myself) love it. Perfect for distracting them on a car journey. We will pass them an iPad and three minutes later you hear the little “sploosh” sounds of them building something having picked it to play.
There are so many little hidden detail to find (look for “round” grid areas, build a tower in the middle then delete the bottom of it and see what happens)
I have been following Oskar on Twitter [0] for last few years, he is such a good communicator. It’s always a joy when one of his posts turned up with the details of the latest thing he is working on. Even if you aren’t interested in game design he is such a good follow.
You can play a demo of Townscaper in your browser here: https://oskarstalberg.com/Townscaper/
0: https://twitter.com/OskSta
mizzao · 2022-06-12
https://oskarstalberg.com/Townscaper/
thrillingly designed, and amazing what can be done in WebGL
t8y · 2021-12-01
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.
[0]http://oskarstalberg.com/game/wave/wave.html
[1]https://www.youtube.com/watch?v=2SuvO4Gi7uY
thdrdt · 2020-07-21
Oscar Stålberg created this 'game' https://store.steampowered.com/app/1291340/Townscaper/
He also has some great talks on YouTube about generating city maps with cube marching and wave function collapse.
His online map generator: http://oskarstalberg.com/game/CityGenerator/
What I like about his approach is that it looks very natural European instead of American.
nxpnsv · 2020-07-21
This was even more amazing to me http://oskarstalberg.com/game/planet/planet.html
DonHopkins · 2023-01-28
I am a huge fan of Sandspiel, which Max described in this article from 2019, and recently I was delighted to discover that he and TodePond have been doing a huge amount of wonderful work since then.
What happens when you combine Sandspiel with a Scratch-like blocks based visual programming language that lets you look inside and see how rules work, tweak and modify them, and even define your own rules for different types of particles? And then form a community around it for sharing
Here is Max's and TodePond's brilliantly ambitious visually programmable sequel, Sandspiel Studio!
https://studio.sandspiel.club/
Here's my profile, where you can play with the version of Max's flower growing rule that he shows here:
https://www.youtube.com/watch?v=ifyYITDq1oo
...to grow underground potatoes and fancy flowers:
https://studio.sandspiel.club/user/clanzgor8006109mtjooi348t
I've written more about Sandspeil Studio and related topics of artificial life, cellular automata, and visual programming, and quoted some interesting discussion with Max and TodePond from their Discord server (they actually already knew about most of this stuff, but they love it as much as I do), in the "Ask HN: What weird technical scene are you fond/part of?" discussion, in reply to api's comment about Digital Artificial Life:
https://news.ycombinator.com/item?id=33698163
api 67 days ago | parent | context | favorite | on: Ask HN: What weird technical scene are you fond/pa...
Digital Artificial Life --…
dejobaan · 2025-10-03
There's a neat demo of this in action here: https://jaxry.github.io/wave-function-collapse/
Another, where you can set cells and then have it solve: https://oskarstalberg.com/game/wave/wave.html
And an itch.io game where you are the wave function selector: https://bolddunkley.itch.io/wfc-mixed
I thought this concept would have found more traction in the world of procgen (in games), because it's pretty neat. But I found it difficult to work with, so perhaps others also did!
simple10 · 2024-06-15
That was my immediate reaction as well. Some part of my brain just prefers building walkways. In the web version, you apparently have to keep adding walkways above a building to convert it to a walkway. Super satisfying.
https://oskarstalberg.com/Townscaper/#IzhCuIQmN6b832-HkACCzFNQQQOtACCz…
michelb · 2024-06-15
yes, a version is here: https://oskarstalberg.com/Townscaper/
thatgamer44 · 2024-06-15
Townscaper also has a Unity WebGL build, for anyone interested:
https://oskarstalberg.com/Townscaper/
Davertron · 2023-10-20
Maybe a bit of a stretch as a game, but Townscaper is absolutely gorgeous: https://oskarstalberg.com/Townscaper/
ohxh · 2023-03-23
There’s an interesting approach similar to this called Wave Function Collapse [1] (no relation to wfc in physics besides inspiration). It can infer the probabilistic constraints from one input example, and it seems to generalize quite well. Here’s a little demo: https://oskarstalberg.com/game/wave/wave.html
[1] https://github.com/mxgmn/WaveFunctionCollapse
Matumio · 2023-01-21
Townscaper is pretty chill: https://oskarstalberg.com/Townscaper/
sorenjan · 2022-11-12
I'd count Townscaper as a toy as well.
https://oskarstalberg.com/Townscaper
waboremo · 2022-10-26
You already can, Unity has their own section of Unity on the web games you can play. They aren't graphically impressive usually but comes down to lack of development resources.
Then there's examples like Townscraper (https://oskarstalberg.com/Townscaper/) which are graphically nice and already playable on the browser. There are also many games on itch.io of varying quality, but IMO Townscraper is the nicest.
The problem of storage is also quite important, it's hard to push a high quality game on the browser when a lot of people won't stick around for the 10GB+ download needed, not like they would if they're downloading from the Xbox store or something like that. So it's a bit of a cultural issue as well on that front.
venthur · 2021-12-02
you can even stack them! https://oskarstalberg.com/Townscaper/#MzJODmugKVfngggBBBC_TMBBBDCCE8EK…
coryrc · 2021-12-02
An arc through the middle can cause no stilts or propellers!
https://oskarstalberg.com/Townscaper/#MzJODmWAdn_ETTo_gSLputjP8oyU3oo9…
(and, for posterity's sake, the shape with propellers is a donut).
chriscjcj · 2021-12-01
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.
http://oskarstalberg.com/Townscaper/#IzhCuCAJioFFB00CAajRAN2AiWdAR32DI…
raajg · 2021-12-01
Wow, the entire town is URL encoded!! Example: http://oskarstalberg.com/Townscaper/#IzpjOEQ0ejP2X9w-b--c-X--A-b_-0-n1…
_Microft · 2021-12-01
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.
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
dvh · 2021-07-18
https://oskarstalberg.com/game/house/Release/UnityLoader.js(1): Invoking error handler due to
Uncaught RangeError: Array buffer allocation failed
ERROR> blob:https://oskarstalberg.com/5b6b4a87-7358-438a-a06d-fd708250936b(1): Uncaught RangeError: Array buffer allocation failed
Scaevolus · 2021-07-18
And he has a prototype of WFC city building online! https://oskarstalberg.com/game/house/index.html
leetrout · 2020-07-25
Related discussion the other day on his webgl toy Brick Block
https://oskarstalberg.com/game/house/index.html
https://news.ycombinator.com/item?id=23904991
hombre_fatal · 2020-07-21
Found a similar thing but with a planet on his blog: http://oskarstalberg.com/game/planet/planet.html
I'm in awe of the attention to detail. This guy is a real artist, cool to see such a skilled mix of creativity, art, and software.
swah · 2017-05-24
Very nice - fast too. Reminds me of something I saw yesterday http://oskarstalberg.com/game/CityGenerator/
This guy makes super cute gifs of his game: https://twitter.com/OskSta
drusepth · 2022-02-15
Other cool generators from other creators also (in addition to those already posted, copied from [1]):
- Azgaar's Fantasy Map Generator: https://azgaar.github.io/Fantasy-Map-Generator/
- Oskar Stalberg's City Generator: https://www.oskarstalberg.com/game/CityGenerator/
- donjon's Fantasy World Generator: https://donjon.bin.sh/fantasy/world/
- Myth Weavers Dungeon Generator: https://www.myth-weavers.com/generate_dungeon.php
[1] https://www.fiction.tools/#worldbuilding-map-generators