isomage

11-20-2013, 06:17 AM

Using a Dielectric Breakdown Model -- essentially, simulated lightning -- produces some interesting-looking results.

They're not very fancy, but might suit a lo-fi game like a roguelike. One nice feature is that they have no disconnected parts, because of the way they're grown.

Algorithm:

1) set the electrostatic potential along the bottom of a grid of cells to 1, and that of a "seed" cell at the top to 0;

2) calculate the potential at every other cell in the grid;

3) find all the cells which are adjacent to a seed cell;

4) choose one of these cells randomly, with probability proportional to its electrostatic potential, and let it become another seed cell with potential 0;

5) if the new cell is at the bottom of the image, or if you've added a pre-determined maximum number of new cells, stop; otherwise, goto 2.

The collection of seed cells grows downward from the original seed cell, sending out random tendrils along the way, until it reaches the bottom, or you run out of cells to place. A parameter in the probability calculation changes the shape, making the pattern straighter or more radial (the probability that a cell in (3) becomes a seed is the nth power of its potential, divided by the sum of the nth powers of all their potentials -- if n = 1, you get normal-looking lightning, if n = 0.5 it's rounder, if n = 1.5 it's straighter). The potential can be found via a "relaxation" method for solving Laplace's equation.

I just realized how mathy this has gotten, and now I doubt anyone would ever use this method, but if you're interested you can google some relevant terms and find more information. For everyone else, it's picture time!

Actually, now I'm thinking this is just utterly stupid, but after spending all this time making this post, I can't bring myself to cancel it.

:D

They're not very fancy, but might suit a lo-fi game like a roguelike. One nice feature is that they have no disconnected parts, because of the way they're grown.

Algorithm:

1) set the electrostatic potential along the bottom of a grid of cells to 1, and that of a "seed" cell at the top to 0;

2) calculate the potential at every other cell in the grid;

3) find all the cells which are adjacent to a seed cell;

4) choose one of these cells randomly, with probability proportional to its electrostatic potential, and let it become another seed cell with potential 0;

5) if the new cell is at the bottom of the image, or if you've added a pre-determined maximum number of new cells, stop; otherwise, goto 2.

The collection of seed cells grows downward from the original seed cell, sending out random tendrils along the way, until it reaches the bottom, or you run out of cells to place. A parameter in the probability calculation changes the shape, making the pattern straighter or more radial (the probability that a cell in (3) becomes a seed is the nth power of its potential, divided by the sum of the nth powers of all their potentials -- if n = 1, you get normal-looking lightning, if n = 0.5 it's rounder, if n = 1.5 it's straighter). The potential can be found via a "relaxation" method for solving Laplace's equation.

I just realized how mathy this has gotten, and now I doubt anyone would ever use this method, but if you're interested you can google some relevant terms and find more information. For everyone else, it's picture time!

Actually, now I'm thinking this is just utterly stupid, but after spending all this time making this post, I can't bring myself to cancel it.

:D