Perlin noise in 2 dimensions expression

From Castle Wiki
Revision as of 22:17, 16 May 2022 by Ben (talk | contribs) (Add motivation for perlin noise)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

See the Wikipedia page on Perlin noise for more information.

Perlin noise is an Expression that takes in two values, an X and Y position, and returns a single value between 0 and 1. The value returned by Perlin noise is a psuedo-random value and can form pleasingly random yet uniformly distributed patterns when viewed alongside neighboring values.

What do I use this for?

This is useful when you want something to feel random, but to change smoothly through space. For example, you could generate random terrain by using the X and Y of the card space as inputs, and assigning the Perlin output to the height of the hills at that location.

Here is an example of a deck that uses Perlin noise. To see how it works, view the source of the deck in Castle, then inspect the blue square actor.