v0.1; caminoix; 30.06.2006
v0.2; caminoix; 10.07.2006
v0.3; caminoix; 27.08.2006
download source | binary
the idea behind the fault algorithm is pretty simple. you divide the map with a random line in two parts. then you elevate one part, and lower the other. repeat a few hundred times, smooth it, and there you go with a very nice looking heightmap.
the one thing you could be more interested in are the implementation details. sure, line drawing algortihms are available in lots of places on the web but the thing is that you don't really need to mess with that. just take a look at how it's done here (this isn't exactly my implementation. i found it on the web a long time ago and only modified it a bit and translated to nemerle. i'm very sorry but i couldn't find it now again to credit the author.):
def x1=r.Next(sizeX); def y1=r.Next(sizeY);
def x2=r.Next(sizeX); def y2=r.Next(sizeY);
for (mutable x=0; x<sizeX; x++) for (mutable y=0; y<sizeY; y++)
sLinesis the number of lines, and
sDisplis the displacement factor.