-
-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Description
I'm developing against an Apple watch Series 7. When I try to generate noise I get the following error:
'Thread 1: Fatal error: Not enough bits to represent the passed value'
I'm passing a seed of 1
It's stemming from this initializer in PermutationTable:
private
init(old_permut:[UInt8], seed:Int)
{
var permutations:[UInt8] = old_permut,
rng:RandomXorshift = RandomXorshift(seed: seed)
for i in 0 ..< 255 - 1
{
permutations.swapAt(i, Int(rng.generate()) & 255) //This line here, it's specifically highlighting the Int(...)
}
self.permut = permutations
}Here is my code where I'm using Gradient Noise:
public static func generate(_ gen: RoidGenerationSettings) -> Asteroid{
let noise = GradientNoise2D(amplitude: 1.0, frequency: 10.0, seed: 1)
var tiles: [[AsteroidTile]] = []
//Generate the base tilemap
for x in 0 ... gen.size {
tiles.append([])
for y in 0 ... gen.size {
//Sample the perlin noise here
let noise_val = noise.evaluate(Double(x), Double(y))
//lower noise_val based on how far nodes are from the center
let size_double = Double(gen.size)
let dist_from_center = abs( (size_double/2.0) - hypot(Double(x), Double(y)))
//Adjust the noice by multiplying it by it's normalized distance from center (Should yield [0, 1] scalar)
//let adjusted_noise = noise_val * ((size_double - (dist_from_center / 2.0 )) / size_double)
let adjusted_noise = noise_val
if adjusted_noise < 0.5 {
tiles[x].append(AsteroidTile(type: .EMPTY))
}else {
tiles[x].append(AsteroidTile(type: .JUNK))
}
}
}
...
Here is the callstack:
Metadata
Metadata
Assignees
Labels
No labels
