i-am-tom / holmes

A reference library for constraint-solving with propagators and CDCL.
https://hackage.haskell.org/package/holmes
MIT License
303 stars 14 forks source link

Thoughts on deterministic shuffling, for repeatable procedural generation? #22

Open byorgey opened 5 months ago

byorgey commented 5 months ago

Hi there, thanks for this lovely library! I have grand plans to (eventually) incorporate procedural generation via wavefunction collapse into https://github.com/swarm-game/swarm/ (it currently has procedural generation but only based on Perlin noise) . However, I was reading the documentation today, and it seems like I want something in between Holmes and Watson:

So I would really like a monad that (1) is built over ST, but (2) does random shuffling based on a seeded PRNG. This seems like it should be totally possible in theory --- from what I can tell Holmes is implemented in terms of shuffle from hedgehog, which has type MonadGen m => [a] -> m [a] and does not itself depend on IO in any way --- the IO only comes in from the use of sample :: MonadIO m => Gen a -> m a, which is one convenient way to run a MonadGen computation but not the only way.

Curious to hear what you think about the possibility of exposing a slightly different API which allows this. I'd be very happy to try to submit a PR if you think it seems reasonable. I saw elsewhere that you mentioned working on a rewrite of this library, so I'm not quite sure what the status is.