diff --git a/src/swarm-scenario/Swarm/Game/World/Compile.hs b/src/swarm-scenario/Swarm/Game/World/Compile.hs index 9325d824a..95e92cceb 100644 --- a/src/swarm-scenario/Swarm/Game/World/Compile.hs +++ b/src/swarm-scenario/Swarm/Game/World/Compile.hs @@ -69,7 +69,7 @@ compileConst seed = \case CMask -> compileMask CSeed -> CConst (fromIntegral seed) CCoord ax -> CFun $ \(CConst (coordsToLoc -> Location x y)) -> CConst (fromIntegral (case ax of X -> x; Y -> y)) - CHash -> compileHash + CHash -> compileHash seed CPerlin -> compilePerlin CReflect ax -> compileReflect ax CRot rot -> compileRot rot @@ -94,10 +94,10 @@ compileMask = CFun $ \p -> CFun $ \a -> CFun $ \ix -> case p $$ ix of CConst b -> if b then a $$ ix else CConst empty -compileHash :: CTerm (Coords -> Integer) -compileHash = CFun $ \(CConst (Coords ix)) -> CConst (fromIntegral (h ix)) +compileHash :: Seed -> CTerm (Coords -> Integer) +compileHash seed = CFun $ \(CConst (Coords ix)) -> CConst (fromIntegral (h ix)) where - h = murmur3 0 . unTagged . from @String @(Encoding.UTF_8 ByteString) . show + h = murmur3 (fromIntegral seed) . unTagged . from @String @(Encoding.UTF_8 ByteString) . show compilePerlin :: CTerm (Integer -> Integer -> Double -> Double -> World Double) compilePerlin = diff --git a/src/swarm-scenario/Swarm/Game/World/Interpret.hs b/src/swarm-scenario/Swarm/Game/World/Interpret.hs index 552455bf2..3704e531d 100644 --- a/src/swarm-scenario/Swarm/Game/World/Interpret.hs +++ b/src/swarm-scenario/Swarm/Game/World/Interpret.hs @@ -59,7 +59,7 @@ interpConst seed = \case CMask -> \b x c -> if b c then x c else empty CSeed -> fromIntegral seed CCoord ax -> \(coordsToLoc -> Location x y) -> fromIntegral (case ax of X -> x; Y -> y) - CHash -> \(Coords ix) -> fromIntegral . murmur3 0 . unTagged . from @String @(Encoding.UTF_8 ByteString) . show $ ix + CHash -> \(Coords ix) -> fromIntegral . murmur3 (fromIntegral seed) . unTagged . from @String @(Encoding.UTF_8 ByteString) . show $ ix CPerlin -> \s o k p -> let noise = perlin (fromIntegral s) (fromIntegral o) k p sample (i, j) = noiseValue noise (fromIntegral i / 2, fromIntegral j / 2, 0)