RuleBook

I’m releasing a new open source library, RuleBook. Inspired by Inform 7‘s rulebook feature, it’s a way to make functions by defining a set of rules to evaluate. RuleBooks let you define functions are easy to mod and update at runtime.

Full Docs

What are rulebooks?

Rulebooks are essentially a fancy form of C#’s Func<> and Action<> generics.

Func<> and Action<> can hold a reference to a C# method, or an lambda expression/statement. But the thing they hold is essentially a black box – you cannot do much with it except run it, or check equality.

RuleBook provies FuncBook<> and ActionBook<>, which work similarly to their counterparts. But these rulebook objects are built out of individual rules, which can be individually inspected and mutated.

Overall, rulebooks give a systematic way of handling a bunch of useful programming patterns, including events, multiple dispatch, modding and code weaving.

Rulebooks are not an elaborate rules evaluation engine, it’s a lightweight way of stitching together bits of functionality.

PuzzleScript Rules

I was watching ThinkyCon, a conference on making puzzle games, and many designers mentioned that they use PuzzleScript to prototype their ideas. PuzzleScript is a puzzle design environment created by increpare, the designer behind Stephen’s Sausage Roll and many other puzzle games.

PuzzleScript is a marvel of economic design. A single text file specifies, all the graphics, levels, sound effects, and all the rules of the puzzle. It uses a custom system to concisely express rules. So concise that the rules of Sokoban can be expressed in a single line.

This efficiency comes because rules are expressed as find-replace rules. That makes it a grammar replacement system, which I last discussed when looking at Ludoscope and Unexplored. But it has many pragmatic features geared toward puzzle design, which I’ll explore in this article.

Continue reading

What Is Procedural Generation

Procedural Generation can be interpreted quite broadly as just “making computers make cool creative things”. People make art, games, music, audio, stories and all sorts of weird things.

I’ve been doing it as a hobbyist for some time, and have become more and more involved: I make tutorials, projects, I sell a tool online for a niche algorithm, and recently taught a “masterclass” at Everything Procedural, the main conference for professionals in the space.

I thought I’d spill some digital ink about what it’s actually about. I get asked often enough, and this will help me clarify my verbal answers.

Continue reading

Jules Takes Over the World

Jules felt stung as he left the psych ward. He wasn’t bothered by the battery of tests they ran – after all, he’d just had a major head accident. Nor was he bothered by the extra time they’d spent holding him as they flew in a neuro specialist to try and understand his extraordinary condition.

No, it was the final remarks as he was approved for release. “Sure, he’s testing off the charts for mental aptitude, perhaps a tenfold gain in thinking speed and memory, but that’s not a reason to hold him in a ward. What’s he going to do, take over the world?”

This, Jules took personally.

Continue reading

Trainright

A still from Steamboat Willie

There’s been a lot of clamour about generative AI for images, like Midjourney or Stable Diffusion. It’s killing creating jobs or whole industries; it’s illegally using copyrighted data for training purposes; it’s eroding the nature of art itself. I’m sure there are many out there who would be happy to see an outright ban on AI image generators and the like.

On the other hand, it’s undeniable that this is a valuable technology. Not just for the corporations making them, but of benefit to the world. Sure, every artist unpaid is someone else’s money saved, but also as the costs of art fall, that democratises everything around art. A friend of mine made personalised Christmas card this year, a small joy of the world that simply would not have occurred before. I co-wrote a custom murder mystery with ChatGPT in barely longer time than it took to play. The lowering skills bar for indie comics and games is something I hope leads to a profusion of new original things, much as digital art and games engines have spurred it in the past.

How can we resolve these things, to have our cake and eat it? Well, society has faced this problem before and has found a solution that, though imperfect, has endured for centuries.

Continue reading

0.999… = 1, with Rigour

I’ve recently seen a lot of demonstrations of why the decimal 0.999… equals 1.

These are endlessly cycling the internet, simply because all the simple explanations aren’t really compelling. You see smart people responding “can’t you just…” or simply not convinced by bare assertion.

The truth is that is that dealing with these things is actually a lot more complex than a glib twitter answer. You should feel uneasy with these explanations. This same subject confused mathematicians of earlier centuries, leading to awkward theories like “infinitesimals”, which ultimately fell out of favour.

I’m going to take you through a proof that 0.999… = 1, with rigour. Rigour is a term used in maths for building from a solid foundation and proceeding from there in sufficiently small steps. Thus, the majority of the article is not the proof but the definitions. How can we talk about infinity in a way that makes sense? The trick, as we’ll see, is to only talk about finite things we already understand, and define infinity in terms of those.

This article is aimed at those with high school level maths. There’s a proof halfway down, but it’s skippable.

Continue reading

Ortho-tiles

Last time, we looked at quarter-tiles. This was an auto-tiling technique for square grids. Each cell in the grid is associated with a terrain (i.e. either solid or empty). Then the squares were split in four, and each quarter was assigned an appropriate quarter-tile.

Otho-tiles extends this procedure to work with irregular grids, even non-square grids. We just have to alter the procedure a little, and be ready to deform the quarter tiles fit in place.

Ortho?

Ortho is a Conway Operator. It can be thought of as the extension of dividing a square into 4. It divides each n-gon into n “kites” or “ortho-cells”. Each kite is a four sided shape containing the cell center, one corner, and the midpoint of the two edges adjacent to that corner.

Kites for some shapes

The appeal of the ortho operation is it can take any polygonal grid, no matter how irregular, and convert it into a grid of 4 sided shapes. And it’s much easier to work with something that has a consistent number of sides.

Continue reading