diff --git a/ClassicalSharp/Generator/Noise.cs b/ClassicalSharp/Generator/Noise.cs index 44eb132f5..6de73366a 100644 --- a/ClassicalSharp/Generator/Noise.cs +++ b/ClassicalSharp/Generator/Noise.cs @@ -14,10 +14,18 @@ namespace ClassicalSharp.Generator { public sealed class ImprovedNoise : Noise { public ImprovedNoise( Random rnd ) { - // make a random initial permutation based on seed, - // instead of using fixed permutation table in original code. + // make a random initial permutation based on rnd's seed, + // shuffle using fisher-yates + for( int i = 0; i < 256; i++ ) - p[i + 256] = p[i] = (byte)rnd.Next( 256 ); + p[i] = (byte)i; + + for( int i = 0; i < 256; i++ ) { + int j = rnd.Next( i, 256 ); + byte temp = p[i]; p[i] = p[j]; p[j] = temp; + } + for( int i = 0; i < 256; i++ ) + p[i + 256] = p[i]; } // TODO: need to half this maybe? diff --git a/ClassicalSharp/Generator/NotchyGenerator.cs b/ClassicalSharp/Generator/NotchyGenerator.cs index 8cf57a929..c1f4dd9dc 100644 --- a/ClassicalSharp/Generator/NotchyGenerator.cs +++ b/ClassicalSharp/Generator/NotchyGenerator.cs @@ -23,7 +23,7 @@ namespace ClassicalSharp.Generator { oneY = width * length; waterLevel = height / 2; blocks = new byte[width * height * length]; - rnd = new Random( 0x5553201 ); // 0x5553201 is flatter. + rnd = new Random( 0x5553200 ); // 0x5553201 is flatter. CreateHeightmap(); CreateStrata(); @@ -108,7 +108,7 @@ namespace ClassicalSharp.Generator { caveY += Math.Cos( theta ) * Math.Cos( phi ); caveZ += Math.Sin( phi ); - theta = deltaTheta * 0.2; + theta = theta + deltaTheta * 0.2; deltaTheta = deltaTheta * 0.9 + rnd.NextDouble() - rnd.NextDouble(); phi = phi / 2 + deltaPhi / 4; deltaPhi = deltaPhi * 0.75 + rnd.NextDouble() - rnd.NextDouble(); @@ -344,7 +344,7 @@ namespace ClassicalSharp.Generator { if( !Check( x, y, z ) ) continue; if( xx == 0 || zz == 0 ) { blocks[index] = (byte)Block.Leaves; - } else if( y != bottomY && rnd.NextDouble() >= 0.5 ) { + } else if( y == bottomY && rnd.NextDouble() >= 0.5 ) { blocks[index] = (byte)Block.Leaves; } }