NoelFB / blah

A small 2d c++ game framework
MIT License
578 stars 52 forks source link

Random module #20

Closed SushilRagoonath closed 1 year ago

SushilRagoonath commented 2 years ago

Hi, Any plans on adding noise/random sampling to this library?

NoelFB commented 2 years ago

Yeah I'm into that idea. Realistically it would be a very simple/light pseudo number generator... I think if you want something really complex/thorough just using the standard library or an existing library specifically designed for that is probably best.

SushilRagoonath commented 2 years ago

Understood, The main reason I ask is that rand() from c doesn't produce very nice randomness and the c++ api is quite daunting. I usually rely on https://github.com/nothings/stb/blob/af1a5bc352164740c1cc1354942b1c6b72eacb8a/deprecated/stb.h#L8360 from stb.h Would perlin noise fall outside the range of this framework? I'm imaging an api like Random rand; rand.seed(seed) rand.int() rand.float() rand.perlin1d(x) rand.perlin2d(x,y) rand.perlin3d(x,y,z)

NoelFB commented 2 years ago

yeah I think something like that sounds cool. I would realistically need to research algorithms to include, although I definitely agree a fast perlin would be super useful.

thomashope commented 1 year ago

This library has a bunch of nice stuff in it, might be a good source of inspiration https://github.com/andrewwillmott/distribute-lib

See Generate.h for a bunch of different random number and sequence generators

RandyGaul commented 1 year ago

Here's a really nice C/C++ random number solution. It produces pretty good numbers, and supports all the basic C types already: https://github.com/RandyGaul/cute_framework/blob/master/include/cute_rnd.h

At some point I'll definitely add perlin 1d, 2d and 3d. It's a bit low-priority but will happen at some point.

NoelFB commented 1 year ago

Yeah this is really nice Randy! I'm not super sure yet but I'm currently of the opinion that it's probably best to keep things like number generators and so on up to existing libraries, and leave "blah" to just doing the core of what I need to get a game off the ground.