Skip to content

Instantly share code, notes, and snippets.

View ivan-r-sigaev's full-sized avatar

Ivan ivan-r-sigaev

View GitHub Profile
@ivan-r-sigaev
ivan-r-sigaev / Perlin.cs
Last active July 25, 2025 19:54 — forked from Flafla2/Perlin.cs
Improved Perlin Noise Implementation in C#
// Algorithm inspired by https://gist.github.com/Flafla2/1a0b9ebef678bbce3215
public class PerlinGen
{
private readonly int[] p; // Randomly shuffled array of values from 0 to 255.
// Values are repeated twice to get performance boost
// from avoiding the use of modulo operator.
public PerlinGen(int seed)
{
def simplifyExpr(target):
out = "" # output
brac = {} # dictionary matching ending positions of brackets to starting positions
bracStac = [] # stack containing positions of unclosed brackets
index = 0 # current position in target
outIndex = 0 # current position in out
skip = 0 # used to skip this many characters
for c in target:
app = ''
if(skip > 0):