[Haskell-cafe] Zippers, Random Numbers & Terrain

Thomas Conway drtomc at gmail.com
Mon Jul 30 02:26:27 EDT 2007


Hi All,

To amuse myself while waiting for test-runs to complete, I was
thinking about random terrain generation. I came across a bunch of
nice posts by Torben Mogensen, where he describes a neat way of
constructing random terrains by recursively subdividing right angled
isosceles triangles. It got me thinking - it's all well and good
subdividing to give more detail as you zoom in, but what about when
you zoom out?

This got me thinking that it would be cool to make an infinite terrain
generator using a zipper, so you can zoom in/out infinitely, and by
implication, infinitely in any direction.

One of the key components that seems to be necessary is a random
number generator zipper. In Mogensen's scheme, you have a number
associated with each point, and when you subdivide, you create a new
RNG seed from the numbers at each end of the hypotenuse which you are
bisecting. These numbers are used to generate height variation. The
trick, is to make the combination order independent (e.g. xor). This
is easy for zooming in, but it's not clear how to do this for zooming
out.

It's probably sufficient to assume a (parameterizable) hashing/mixing
scheme, and to simply number the nodes in some deterministic fashion.
The subdivision is binary, so we could number the children
deterministically. If we use "decimals", from some arbitrary starting
point, we can extend in the "fractional" direction when we zoom in,
and extend in the "whole number" direction.

I'm only just discovering zippers, so my question to the learned
members of this forum is: Am I on the right track? Is a scheme like
this going to work?

cheers,
Tom
-- 
Dr Thomas Conway
drtomc at gmail.com

Silence is the perfectest herald of joy:
I were but little happy, if I could say how much.


More information about the Haskell-Cafe mailing list