January 20th, 2009

Random Neighborhood Generator
I was wondering how visually interesting a randomly generated neighborhood could be a made by using simple binary subdivision. Basically the algorithm starts with a square, cuts it in half, cuts those halves in half, and so on to produce streets and plots of land.
It is in no way how a real neighborhood would be laid out, but for such simplicity I am rather satisfied with the results. Such a system could randomly produce results that are visually interesting enough for possibly a small, simple flying or driving based game — such as having to rush a firetruck to burning homes, for example.
Here is the source code: neighborhood.py
Tags: experiments, generator, neighborhood, python, random
Posted in Programming | No Comments »
November 6th, 2008
Every so often I decide to write simple test programs in Python just for the fun of it. Here are a few that I had written over in the past. Please note, because these were originally just simple experiments the source code could be a little messy and poorly optimized in most of them. Also note, these are not meant to be all that impressive.
All of the programs require Python and PIL (The Python Imaging Library.)
Simple Recursive Maze Generator

Simple Recursive Maze Generator
This is just a simple maze generator that uses a recursive function. It creates a near-infinite number of random mazes.
Source: maze.py
Rectangle Packing

Rectangle Packing
I wanted to figure out a simple and effective way of packing rectangle images in an OpenGL texture — which is useful for hardware accelerated 2D graphics. The solution I came up with simply subdivides the availible free space and packs the rectangles from largest to smallest. It may not produce the best packing results and there are quite a few wasted cycles in this implimentation, but, for being as simple as it is, it produces fairly reasonable results rather quickly.
Source: rect_packing.py
Simple Error Diffused Dithering

Error Diffuse Dithering
Just simple error diffusion based image dithering. The above image is showing four color dithering.
Source: dither_test.py
Random Forest Path

Random Paths Through a Forest
I decided to try to see if I could easily produce a visual effect resembling erosion patterns in a forest area. This was part of some preliminary work in trying to write a game that randomly generates a completely different world each time it’s played. The results were very satisfying considering how simple the solution is. Essentially it’s just squiggly lines of varying thickness with some textureing applied to it.
Source: forest_path.py
Image Outlining

Outlining an Image
Originally I wanted to see if I could have interesting features of an image identified and later used in some sort of image recoginition system. Hilighting sharp edges brought out too many points to practically be used for comparing spacial relationships and proportions, but it did produce some nice results for drawing outlines on an image.
I wanted to test it on a picture of a person, so I found the above image online. It is actually a composit of 32 american male faces averaged together. I hope the creators of the website he’s from does’t mind.
Source: img_outline.py
Tags: experiments, python
Posted in Programming | 1 Comment »