mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 18:45:23 -04:00
Minor corrections to noise and map generation as per clarification from Jerralish.
This commit is contained in:
parent
6adb2eec42
commit
bbd933aa20
@ -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?
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user