[Haskell-cafe] Re: Zippers, Random Numbers & Terrain
Martin Lütke
prionic at gmx.de
Mon Jul 30 06:24:52 EDT 2007
apfelmus <apfelmus <at> quantentunnel.de> writes:
>
> Thomas Conway wrote:
> > 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?
>
> Can you post a hyperlink for an exact description of the algorithm?
>
> > 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.
>
> An infinite random terrain sounds like great fun :) I can't say whether
> it's possible or whether zippers are needed without knowing the details,
> though.
>
> One problem is probably having a "point of reference", i.e. one needs a
> point (0,0) with a fixed height 0. In the bounded case, one has a
> rectangle to subdivide instead.
>
> Regards,
> apfelmus
>
You might want to consider Perlin-Noise:
http://wiki.delphigl.com/index.php/Perlin_Noise (good introduction)
It uses a chaotic function (ergodic?) that works on integers. In the case of
Terrain it uses 2. One for the x and one for y coordinate. It should be infinite
for Zooming out. When zooming in one uses interpolation. The drawback(?) is when
zooming out is that it becomes more "noisy". When zooming in it becomes less.
The advantage is that you dont need a reference point. That means you can render
any portion of your infinite terrain without tracing back to the origin.
But I fear you would need a reference point if you want to attach other kinds of
data (not just the hight) with each point. Of course you could layer another
perlin-noise for plants and another for rivers. But in the end all this will get
boring pretty soon because its static.
More information about the Haskell-Cafe
mailing list