public bool AllowRepeat( uint EntryNum, SaltyRandomGenerator RandomGen ) { uint RandomNumber = (uint)RandomGen.GetEntropy( 11, false ); return RandomNumber < Infos[EntryNum].RepeatChance; }
public uint GetTypeNum( SaltyRandomGenerator RandomGen ) { uint Pivot, Step; uint RandomNumber = (uint)RandomGen.GetEntropy( 11, false ); //RandomNumber &= 0x7fffffff; Pivot = EntryCount >> 1; Step = Pivot >> 1; while( true ) { if( RandomNumber < Bounds[Pivot].Low ) Pivot -= Step; else if( RandomNumber > Bounds[Pivot].High ) Pivot += Step; else return ( Pivot ); Step = Step >> 1; if( Step == 0 ) Step = 1; // Bound checking enabled to track errors. if( VoxelGlobalSettings.COMPILEOPTION_BOUNDCHECKING ) if( Pivot >= EntryCount ) throw new Exception( "Out Of Bounds" ); } return ( 0 ); }
public bool IsBelowFence( SaltyRandomGenerator RandomGen ) { uint num = (uint)RandomGen.GetEntropy( 11, false ); if( num < FirstFenceBound ) return true; return false; }
private void Random_getsalt( SaltyRandomGenerator.SaltData add_data_here ) { add_data_here.Clear(); add_data_here.salt_data.Add( BitConverter.GetBytes( Seed ) ); }
private void RandomGen_getsalt( SaltyRandomGenerator.SaltData add_data_here ) { add_data_here.Clear(); add_data_here.salt_data.Add( BitConverter.GetBytes( random_seed[0] ) ); add_data_here.salt_data.Add( BitConverter.GetBytes( random_seed[1] ) ); add_data_here.salt_data.Add( BitConverter.GetBytes( random_seed[2] ) ); add_data_here.salt_data.Add( BitConverter.GetBytes( random_seed[3] ) ); }
public Genesis() { int i; // char to num RandomGen = new SaltyRandomGenerator(); RandomGen.getsalt += RandomGen_getsalt; for( i = 0; i < 256; i++ ) ConvCN[i] = 0; for( i = 0; i <= 9; i++ ) ConvCN[i + '0'] = (ushort)i; for( i = 0; i < 26; i++ ) ConvCN[i + 'A'] = (ushort)( 10 + i ); for( i = 0; i < 26; i++ ) ConvCN[i + 'a'] = (ushort)( 36 + i ); }
void GenerateAddBombs( VoxelSector Sector, double Probability, ushort VoxelType, bool SetActiveSector ) { int x, z, xs, ys, zs, GenerationRadius; SaltyRandomGenerator Random = new SaltyRandomGenerator(); //int Seed; ushort ZoneType = 0; uint RandNum, Ratio; xs = Sector.Pos_x << VoxelSector.ZVOXELBLOCSHIFT_X; ys = Sector.Pos_y << VoxelSector.ZVOXELBLOCSHIFT_Y; zs = Sector.Pos_z << VoxelSector.ZVOXELBLOCSHIFT_Z; //Seed = xs + 3524*ys + 234 * zs; Ratio = (uint)( 1024 * Probability ); GenerationRadius = 0; Random.Reset(); random_seed[0] = xs; random_seed[1] = ys; random_seed[2] = zs; random_seed[3] = 0; for( x = xs - GenerationRadius; x < ( xs + 16 + GenerationRadius ); x++ ) for( z = zs - GenerationRadius; z < ( zs + 16 + GenerationRadius ); z++ ) { if( ( RandNum = (uint)RandomGen.GetEntropy( 10, false ) ) < ( Ratio ) ) // 6 // if ( (((x & 31) == 0) && ((z & 31) == 0)) ) // if ( Canva_4.GetPoint_Fast( x & 255, z & 255 ) != 0) { ZVector3L Position; ZVector3L Offset; Position.x = x - xs; Position.z = z - zs; Position.y = ( GetZoneHeight( x, z, ZoneType ) - ys ); if( Position.y < 64 && Position.y > 0 ) { Sector.SetCube( Position.x, Position.y, Position.z, VoxelType ); if( SetActiveSector ) Sector.Flag_IsActiveVoxels = true; } } } }
void Generate_Generic_PlaceVoxel( VoxelSector Sector, ushort VoxelType, GenericCharCanvas LocationMap, int Offset, int RelativeHeight, bool SetActiveSector ) { int x, z, xs, ys, zs, GenerationRadius; SaltyRandomGenerator Random = new SaltyRandomGenerator(); //int Seed; ushort ZoneType = 0; // uint RandNum, Ratio; xs = Sector.Pos_x << VoxelSector.ZVOXELBLOCSHIFT_X; ys = Sector.Pos_y << VoxelSector.ZVOXELBLOCSHIFT_Y; zs = Sector.Pos_z << VoxelSector.ZVOXELBLOCSHIFT_Z; //Seed = xs + 3524*ys + 234 * zs; uint SizeMask; SizeMask = (uint)( LocationMap.Width - 1 ); GenerationRadius = 0; for( x = xs - GenerationRadius; x < ( xs + 16 + GenerationRadius ); x++ ) for( z = zs - GenerationRadius; z < ( zs + 16 + GenerationRadius ); z++ ) { // if ((RandNum = Random.GetNumber( abs(x) + ( abs(z) << 8 ) )) < (Ratio)) // 6 // if ( (((x & 31) == 0) && ((z & 31) == 0)) ) if( LocationMap.GetPoint_Fast( (int)( SizeMask - ( ( x + Offset ) & SizeMask )), (int)(( z + Offset ) & SizeMask) ) > 128 ) { ZVector3L Position; Position.x = x - xs; Position.z = z - zs; Position.y = ( GetZoneHeight( x, z, ZoneType ) - ys ) + RelativeHeight; if( Position.y < 64 && Position.y > 0 ) { Sector.SetCube( Position.x, Position.y, Position.z, VoxelType ); if( SetActiveSector ) Sector.Flag_IsActiveVoxels = true; } } } }