public int Hash(int x, int y)
{
int a = Seed;
a=a-x; a=a-y; a=a^(int)((uint)y >> 13);
x=x-y; x=x-a; x=x^(a << 8);
y=y-a; y=y-x; y=y^(int)((uint)x >> 13);
a=a-x; a=a-y; a=a^(int)((uint)y >> 12);
x=x-y; x=x-a; x=x^(a << 16);
y=y-a; y=y-x; y=y^(int)((uint)x >> 5);
a=a-x; a=a-y; a=a^(int)((uint)y >> 3);
x=x-y; x=x-a; x=x^(a << 10);
y=y-a; y=y-x; y=y^(int)((uint)x >> 15);
return y;
}
{
int a = Seed;
a=a-x; a=a-y; a=a^(int)((uint)y >> 13);
x=x-y; x=x-a; x=x^(a << 8);
y=y-a; y=y-x; y=y^(int)((uint)x >> 13);
a=a-x; a=a-y; a=a^(int)((uint)y >> 12);
x=x-y; x=x-a; x=x^(a << 16);
y=y-a; y=y-x; y=y^(int)((uint)x >> 5);
a=a-x; a=a-y; a=a^(int)((uint)y >> 3);
x=x-y; x=x-a; x=x^(a << 10);
y=y-a; y=y-x; y=y^(int)((uint)x >> 15);
return y;
}
This algorithm is quite fast, and generates pretty decent random numbers. The two input parameters lets me hash 2D points.
Right now I'm stuck on one problem: how do I get infinite reproducible complexity? It's easy to zoom infinitely into a fractal and generate complexity on the fly, but it's much harder to be able to zoom out. That means everything generated when zooming in needs to follow a deterministic pattern so I can reproduce it when zooming out. Hashing seems to solve that, but then what input coordinates do I use? As I zoom in, I start to lose accuracy as the coordinates get really large (or really small) if I am using a global coordinate system. I don't know if I can get infinite complexity using global coordinates, but if I use local coordinates, it might not be all reproducible. I'm still figuring this one out.