Procedural tree generator #

I'm still a bit sad about Flash going away. Yes, I know lots of people hated it. But it was an amazing tool for creativity. One of the tiny fun projects I did was procedurally generating trees:

Set of procedurally generated trees
Procedurally generated trees

Upgrading my PRNG for procedural generation #

For a long time now I've been using a very simple Park-Miller LCG random number generator for my procedural generation projects. This is in part because back in the Flash days, Michael Baczynski's "polygonal.de" library was popular, and it had an implementation of Park-Miller. When I switched to Haxe, I used his Haxe data structures library. And then when I switched to Javascript, I used the Javascript port of polygonal's library, and then I wrote my own. I love how simple the core algorithm is.

However I know that it's not a great random number generator.

The original Flash version and the Javascript port both point to Robin Whittle's page about this algorithm, which explained that 16807 was the original multiplier used in this random number generator, but that "47271 or 69621" would be better. I ended up making my own code that used 47271. But I noticed today that the Wikipedia page says 48271 is better, so I'm wondering if 47271 is a typo. So I looked at the paper and indeed, 48271 and 69621 are listed. Not 47271. So for years now I've been using a multiplier based on a typo.

Doh!

Labels:

Improving island shaping for map generation, again #

Back in 2019 I rewrote the island section of my noise-based map generation page. I had high hopes for that rewrite. It was ok, but I was still quite unhappy with it. So I rewrote it again.

Island map generation: demo and main ideas

Labels:

Offline access with File / Save As #

One of my low priority goals for my site is to make my pages work offline. I had looked into "web manifests" but they seem more suited for web apps and not for documents like mine. So I looked at what it would take to make File→Save As work, preserving interactivity. It turns out it does not work in general on my site. Why?

I tried to make the original HTML + JavaScript should work offline in the sense that they only access resources on the current server and not from any CDN, Google Fonts, etc. So if you save the HTML + JavaScript it should work on a local web server. However, File→Save As doesn't work this way!

Diagram showing what happens when using Save As in the browser on an interactive page
Save As for an interactive page (diagram made with excalidraw)

Labels:

Ten Years of Red Blob Games #

Wow, it's been over ten years now for Red Blob Games. I had started experimenting with interactive diagrams in Java back in the early 2000s, and wrote a blog post in 2007 about why I wanted them. My early experiments weren't entirely satisfactory. Although Flash applets worked better than Java applets, they both produced the diagrams alone, not the whole page. Once HTML5 became widely available in 2011, I started learning how to make interactive diagrams with it. I concluded that HTML5 would let me create the unified experience of interactive text+diagrams that I wanted. I started Red Blob Games in late 2011 to explore this style of interactive articles, which Bret Victor called "explorable explanations".

Screenshots of various projects I've worked on in ten years

Reaction-diffusion #

I'm following Phillip Compeau's online biology+math course, and it starts out with reaction-diffusion systems. I've played with them several times before, most recently in 2019, but with this course it finally "clicked" how they work. I have this experience often — I have to play with something before I can understand it.

Reaction-diffusion patterns
Reaction-diffusion patterns