Fiddling Weights with Temperature

In procedural generation, the absolute simplest, most common technique is randomly picking an item from a list. More often than not, it is a weighted random choice, where each item is selected with a frequency proportional to its “weight”, a numerical value that can be tweaked by the designer.

def random_choice(items: list, weights: list[float]):
    total_weight = sum(weights)
    random_value = random.random() * total_weight
    
    # Find the item that corresponds to the random number
    for i, weight in enumerate(weights):
        random_value -= weight
        if random_value <= 0:
            return items[i]

I wanted to share a technique from the Machine Learning community that is simple enhancement to this routine that gives a lot of convenience over tweaking weights directly, called temperature.

Continue reading

The A/B Not Taken

Thank you for your interest in FrostGPT™.
Rate which response you like the most?

Response 1

Two roads diverged in a yellow wood,
And sorry I could not travel both
And be one traveler, long I stood
And looked down one as far as I could
To where it bent in the undergrowth;

Then took the other, as just as fair,
And having perhaps the better claim,
Because it was grassy and wanted wear;
Though as for that the passing there
Had worn them really about the same,

And both that morning equally lay
In leaves no step had trodden black.
Oh, I kept the first for another day!
Yet knowing how way leads on to way,
I doubted if I should ever come back.

I shall be telling this with a sigh
Somewhere ages and ages hence:
Two roads diverged in a wood, and I—
I took the one less traveled by,
And that has made all the difference.

Response 2

Two paths diverged in an autumn wood,
And sorry I could not journey both
And be one wanderer, long I stood
And gazed down one as far as I could
To where it curved in the undergrowth;

Then saw another, as equally fair,
And having perhaps the stronger claim,
Because it was verdant and needed wear;
Though as for that the passing there
Had worn them truly about the same,

And both that morning equally lay
In leaves no foot had trodden black.
Oh, I saved the second for a future day!
Yet knowing how path leads on to path,
I questioned if I should ever come back.

I shall be sharing this with a sigh
Somewhere decades and decades hence:
Two paths diverged in a wood, and I—
I took the one more traveled by,
And that has made all the difference.

Exploring Rectangle Subdivisions

Last week, I saw a talk on Vuntra City, a procedurally generated city with a fully explorable city. Developer Larissa Davidova explained that she settled on using Recursive Subdivision for the city blocks, as she wanted some level of organicness, while still only having to deal with rectangles. But she didn’t like having indefinitely long roads that cause implausible sightlines.

One way Vuntra City handles this is by subdividing a rectangle into 5 blocks, a pattern I called “whirl” in my previous article on recursive subdivision. You can see that it has no internal roads that stretch across the entire map.

But Larissa’s talk got me thinking. The whirl pattern is interesting because it cannot be made from simple cuts. What other ways of subdividing a rectangle into smaller rectangles1, are out there?

Continue reading

Running Tracery bots with LLMs

Tracery bots were a fun, simple, way of making generative texts. They are basically an easy way to specify generative grammars via a simple JSON file format. There used to be a horde of fun little tracery bots on twitter until API changes shut them all down.

Nowadays, you can prompt a chatbot to get whatever you want. But that lacks the same charm, and it doesn’t give you the control you’d want for something unleashed on the internet. Let’s do something about that.

Continue reading

Ozymandias²

I met a scholar from an English class
Who said: In dusty archives, seldom passed,
There lies a sonnet, once of mighty fame.
Near it, on yellowed pages, time-worn, lame,
The dedication reads: “Percy Bysshe Shelley,
Who spoke to power through his burning hymns,
Few now recall, save students, grudgingly.
He wrote of Ozymandias, King of Kings;
Look on his verse, ye readers, and despair!”
Round the decay of that poetic feat,
Bare margins stretch, and in the desert there
His words drift forgotten, like windblown heat.