Getting More out of Seamless Tiles

tiles_header_smallI wrote an article for Dev.Mag covering some techniques for working with seamless tile sets such as making blend tiles, getting more variety with procedural colour  manipulation, tile placement strategies, and so on. 

Check it out!

The Python Image Code has also been updated with some of the algorithms explained in the article.

Cellular Automata for Simulation in Games


A cellular automata system is one of the best demonstrations of emergence. If you do not know what cellular automata (CA) is, then you should go download Conway’s Game of Life immediately:

Conway’s Game of Life

Essentially, CA is a collection of state machines, updated in discrete time intervals. The next state of one of these depends on the current state as well as the states of neighbours. Usually, the state machines correspond to cells in a grid, and the neighbours of a cell are the cells connected to that cell. For a more detailed explanation, see the Wikipedia article.

Even simple update rules can lead to interesting behaviour: patterns that cannot be predicted from the rules except by running them. With suitable rules, CA can simulate many systems:

  • Natural phenomena: weather, fire, plant growth, migration patterns, spread of disease.
  • Socio-economic phenomena: urbanisation, segregation, construction and property development, traffic, spread of news.

Continue reading “Cellular Automata for Simulation in Games”

A simple texture algorithm – faster code and more results


Faster Code

A while back I wrote about a simple texture algorithm that I have been exploring. The Python implementation was very slow – so much, that I decided to implement it in C++ to see what performance gain I would get. Surprisingly, the C++ version is about 100 faster, if not more. I expected a decent increase, but what once took several hours can now be done in a minute!

Continue reading “A simple texture algorithm – faster code and more results”

Random Steering – 7 Components for a Toolkit

Random steering is often a useful for simulating interesting steering motion. In this post we look at components that make up a random steering toolkit. These can be combined in various ways to get agents to move in interesting ways.

You might want to have a look at Craig Reynolds’ Steering Behaviour for Autonomous Characters — the wander behaviour is what is essentially covered in this tutorial. The main difference is that we control the angle of movement directly, while Reynolds produce a steering force. This post only look at steering — we assume the forward speed is constant. All references to velocity or acceleration refers to angular velocity and angular acceleration.

Whenever I say “a random number”, I mean a uniformly distributed random floating point value between 0 and 1.

Continue reading “Random Steering – 7 Components for a Toolkit”

Python Image Code

I use this code to illustrate many of the tutorials on this site, and the articles I write for Dev.Mag. Ideally, I would like to package the code so that it is the minimal necessary for the particular tutorial; however, a lot of the code is reused, so that it becomes difficult to maintain. Instead, I distribute it all together. That way, new updates and extensions can be found in one place.

The current version includes classes and functions for:

  • easy-syntax 2D and 3D arrays (for example, you can use grid[1:20:2, 2:3:20] to access the pixels in every second column (starting with column 1 and ending before column 20) and every third row (starting from row 2 and ending before row 20) (docs);
  • general image utility function (docs);
  • perlin noise (docs, tutorial);
  • poisson-disk sampling (docs, tutorial);
  • texture generation algorithms (docs, tutorial);
  • quadtrees (docs, tutorial part1 and part 2);
  • classes for generating random points (1D and 2D) from arbitrary distributions (docs, tutorial);
  • functions for blending between images (for smooth transitions between regions in seamless tile sets) [see, tutorial];  and
  • functions for image quilting (under construction).
A few notes:
  • The code is not optimised, and in general convenience and clarity takes precedence over speed. This code is not suitable for many applications where speed is important.
  • The code will change often. At this stage I do not try to make it backwards compatible.


Python Image Code v0.6 (593 KB)

Requires PIL (Python Image Library).

This version includes some of the dependencies that accidentally got left behind in the previous version.