Results 1 to 4 of 4

Thread: Caves via simulated lightning

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Default Caves via simulated lightning

    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.

    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	lightning.png 
Views:	76 
Size:	4.0 KB 
ID:	59171   Click image for larger version. 

Name:	lightning2.png 
Views:	66 
Size:	4.2 KB 
ID:	59172   Click image for larger version. 

Name:	lightning3.png 
Views:	57 
Size:	4.0 KB 
ID:	59173   Click image for larger version. 

Name:	lightning4.png 
Views:	63 
Size:	4.2 KB 
ID:	59174   Click image for larger version. 

Name:	lightning5.png 
Views:	48 
Size:	4.0 KB 
ID:	59175  

    My random map generators and GIMP scripts: http://axiscity.hexamon.net/users/isomage/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •