Some of my tools and software have been arond for some time. Plenty of people use them them, judging from queries and stats I see, but few write back to tell me where it’s actually been used. Here I document some of the published projects. I’m always pleased to see more.
Continue readingUncategorized
Defining Chess Piece Moves using Regular Expressions
Suppose you wanted to code a simple chess game. One key bit of game logic is to describe what are legal moves for each piece. There’s only 6 types of piece (pawn, knight, bishop, rook, queen, king) so this isn’t exactly a hard task. You can write rules such as:
def canRookMove(from, to):
# Ignores questions about colliding with other pieces
return (from.x == to.x or from.y == to.y) and from is not to
But these days, I’ve been thinking a lot about grids, and the above approach just doesn’t generalize. What if you wanted to play chess on a stranger grid?

What would it mean to play chess on the grid above, or a hexagonal grid, and so on? You’d have to write a whole new set of rules, and they could get very complicated depending on the grid in question. What I want is a language that describes how pieces move, which generalizes to any board. And I think I’ve found it, using regular expressions.
Continue readingTessera: A Practical System for Extended WaveFunctionCollapse
I’ve been working a lot on Tessera. I presented a paper at the most recent PCG Workshop of FDG, where I explain how Tessera makes WaveFunctionCollapse somewhat less daunting, and go into some of the details of its features.
That may not be news for users of the software, but here I explain how things work, and what parts work well / I’m especially proud of.
Using Unity’s TextGenerator.verts
TextGenerator.verts is meant to give the position information of every character in a given string. This is useful in Unity if you need to align something with exactly where some particular text is occuring, if for some reason you are not already using TextMeshPro.
Older Unity versions created 4 verts for every character, which made life easy. But now many non-rendering characters don’t have verts generated for them, and the relationship between verts and characters is undocumented. I’ve reverse engineered it, as best as I can tell:
int? GetVertForPosition(int position, string text, TextGenerator textGenerator)
{
var c = 0;
var vert = 0;
for (var i = 0; i < position; i++)
{
if (textGenerator.characters.Count <= c)
return null;
if (!char.IsWhiteSpace(text[i]) && textGenerator.characters[c].charWidth > 0)
vert += 4;
if (text[i] != '\n')
c++;
}
return vert;
}
New Discord Server
Let’s face it, running your own WordPress blog is a sign you are woefully out of date. I can see plenty of readers, but never hear from them.
So I’ve created a Discord server. Feel free to log on and ask me support questions about my projects, suggest new article ideas, or just to hang out.
Don’t worry, the blog isn’t going anwhere. I think the jump might kill me if I leaped fully into the 21st century.
Lucky Fluke Post Mortem
I recently made a game in 48 hours, Lucky Fluke. Though technically I’ve done game jams before, I’ve not done one in a decade, and not ever as successfully. So I thought I’d write up what I learnt.
Continue readingRandom Path Algorithm
Quick follow up to my previous post, I found the same technique is pretty good at generating organic looking random paths. You simply start with an empty room, and keep randomly filling points until it is no longer possible to add any more without disconnecting the room. What’s left is a nicely wiggly pathway.
Fast Traversal Queries of Procedurally Generated Rooms
X Gems of AS3 Language Design
Ok, so AS3 has its fair share of problems. It is slow, it has next to no support for templates/generics and somewhat sparse standard library. And yet still I love using it.
Why? It has managed to pull together some of the rarer features that I think every language should have. Language designers, take note of the following.
Release of Box2DFlash 2.1a
I’m releasing an alpha version of Box2D Flash 2.1. It’s got a shiny new website, too. It has may features that were lacking before, but you’ll have to discover most of them for yourself.
This move is prompted mainly by the announcement of Erin that Box2D 2.1 itself is going to be delayed for more features. Also, the wiki got wiped out, so documentation is at an all time low (frankly, I’m glad the wiki’s gone. I sunk much work into it, but it was still a useless reference source).
Code is still alpha quality, which means a) bugs, b) no guarantees for changes in syntax. The big stuff is out of the way though. If you find a bug, or have a complaint, please post it to the forum as a new thread starting, or the sourceforge issue tracker. Do not post it as a comment here. A comment amongst other comments is too easily lost.Bear in mind that I will almost certainly ask for a testbed demonstrating the bug.
BTW, I’m going away for a couple of days for TIGJam:UK, so don’t expect issues to be treated immediately.