Using a permutation table for simplex noise without storing it

Posted by J. C. Leitão on Game Development See other posts from Game Development or by J. C. Leitão
Published on 2013-11-10T10:07:02Z Indexed on 2013/11/10 10:18 UTC
Read the original article Hit count: 248

Generating Simplex noise requires a permutation table for randomisation (e.g. see this question or this example).

In some applications, we need to persist the state of the permutation table. This can be done by creating the table, e.g. using

def permutation_table(seed):
    table_size = 2**10  # arbitrary for this question
    l = range(1, table_size + 1) 

    random.seed(seed) # ensures the same shuffle for a given seed
    random.shuffle(l)
    return l + l  # see shared link why l + l; is a detail

and storing it.

Can we avoid storing the full table by generating the required elements every time they are required?

Specifically, currently I store the table and call it using table[i] (table is a list). Can I avoid storing it by having a function that computes the element i, e.g. get_table_element(seed, i).

I'm aware that cryptography already solved this problem using block cyphers, however, I found it too complex to go deep and implement a block cypher.

Does anyone knows a simple implementation of a block cypher to this problem?

© Game Development or respective owner

Related posts about maps

Related posts about procedural-generation