Minor corrections to noise and map generation as per clarification from Jerralish.

This commit is contained in:
UnknownShadow200 2015-12-06 20:35:49 +11:00
parent 6adb2eec42
commit bbd933aa20
2 changed files with 14 additions and 6 deletions

View File

@ -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?

View File

@ -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;
}
}