I’ve released a new library, Sylves that handles the geometry of grids for C# or Unity. I’ve basically distilled all my knowledge from several different grid projects, and made a solid base for anything you might want.
Constrained Text Generation with AI
I was discussing how AI text generation, such as ChatGPT, might end up getting used in computer games. So far, designers are fairly reluctant to adopt the technology. One of the key problems is that you just can’t control the output enough. Language models will break character or respond in inappropriate and toxic ways. Finding a good solution to this is a huge research field, and not likely to get cracked soon.
For the foreseeable future, AI in games is much more likely to be used offline – assets and dialog generation generated up front, so it can be vetted before being integrated into the game.
But it got me thinking, can we vet the AI’s output in advance, but still get the benefits of intelligent decision making at runtime? It turns out, we can! I doubt it’ll be useful in every circumstance, but I can certainly see uses for it, like chatbots, games.
The code and demonstration for this article is available here.Continue reading
Infinite Quadtrees – Fractal Coordinates
A cool technique I’ve wanted to write up for a while is “Fractal Coordinates” described in a paper by Peter Mawhorter. Don’t be scared by the name, it’s essentially a variant on quadtrees that covers the entire 2d plane. Fractal coordinates have some interesting properties that are useful for procedural generation.
But first, let’s catch up on quadtrees.Continue reading
How does Planet Work
It’s been over a year since I last deconstructed how a game does its procedural generation. Today we’ll be looking at Planet, a 2016 cosy design toy by one of my favourite developers, Oskar Stålberg.Continue reading
Everything you need to know about Quaternions for Game Development
They represent 3d rotations.
That’s it, that’s the article.Continue reading
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 reading
Learning to Finish Things
For many years I was a hobbyist programmer. I’d try out small projects, experiment, then move on to the next thing. This was a great way to learn a lot, but I’ve got almost nothing tangible to show from that era. Despite the best of intentions, every project reached a point where it started to drag, and I’d get bored and move on.
It was only a problem for the projects I worked on myself. Working for others, I never really found the same problems. It was a problem of motivation and focus.
More recently, it is different. Now when I start hobby projects, there’s a good chance I’ll cross that finish line, and have something I’m ready to share with the world. What changed? Well in part it is increased experience and maturity, things I cannot teach. But also, I have found some strategies and thought processes helpful, and other, very tempting ones, not so much.
In short, I’ve learned to finish, which is a real skill you can learn over time. I thought I’d share with you what has worked for me. Maybe it’ll work for you too. I make software, but I think this advice is generally true for any other spare time activities. There’s three sections – scope, motivation and distractions.Continue reading
I’ve relased a new library, VoronatorSharp.
VoronatorSharp is a C# library that computes Voronoi diagrams. The Voronoi diagram for a collection of points is the polygons that enclose the areas nearest each of those sites.
Voronoi diagrams have applications in a number of areas such as computer graphics.
This library features:
- Computes Voronoi diagrams and Delaunay triangulations.
- Voronoi polygons can be clipped to a rectangular area.
- Uses a
n log(n)sweephull algorithm.
- The implementation attempts to minimize memory allocations.
- Integrates with Unity or can be be used standalone.
- Uses robust orientation code.
- Handles Voronoi diagrams with only 1 or 2 points, and collinear points.
Graphs are a data structure we’ve already talked a lot. Today we’re looking at extension of them which is both obvious and common, but I think is rarely actually discussed. Normal graphs are just a collection of nodes and edges, and contain no spatial information. We’re going to introduce rotation graphs (aka rotation maps) that contain just enough information to allow a concept of turning left or right – i.e. rotation.Continue reading
As a side-project of a side-project, I’ve made a little painting program. It’s like a normal paint program, only you paint on a tile grid instead of pixels. You can create mosaic and stained-glass style images.Continue reading