Gunivers / Bookshelf

📚 Bookshelf is a modular library datapack designed to simplify complex systems in Minecraft maps. Ideal for mapmakers looking for easy-to-implement tools.
http://bookshelf.docs.gunivers.net
Mozilla Public License 2.0
39 stars 12 forks source link

🎲 Implement `bs.random` module! #228

Closed SBtree-bit closed 3 weeks ago

SBtree-bit commented 3 months ago

Tasks to do before merging

aksiome commented 3 months ago

For the documentation a lot of nbt have the wrong types. On top of that a lot of sentences are missing a dot at the end and ':' for examples. Also we discussed a bit with Theo about interfaces and here is what we think should be best. If you have better ideas or you think something is bad don't hesitate to tell us. Naming things can be hard and we're always open for discussion.

#bs.random:binomial

[inputs] trials: [int] probability: [double] (instead of chance? and use a double in range [0,1] instead of a scaled number, it can easily be stored then retrieve from the storage in a scaled way, but it's easier to understand for the user)

#bs.random:geometric

[inputs] probability: [double] (same as before double in range [0,1] instead of a scaled number)

#bs.random:poisson

[inputs] lambda: [double] (same as before, better not to use a scaled number)

#bs.random:choose

[inputs] bs:in random.choose.options (instead of bs:in random.choose.list)

[outputs] bs:in random.choose (instead of bs:out random.choose.selection)

#bs.random:white_noise

[inputs] width: [int] height: [int] range: (remove it? it's unused in the code, or maybe i missed something) with: callback: [str] (instead of function, also even if it's not really useful we think it should accept a command and not just a function) spacing: [int] (i think it should be the number of tiles to generate instead of rows) (should have a default value this way dont need to define it if a callback is given) postpone: [bool] (should have a default value (not sure which is best, maybe false?))

[outputs] bs:out random.white_noise (instead of bs:out random.noise) A two-dimensional array of 0s and 1s, with the size of width by height. (Not really clear it's a two dimensional array of values in range 0,1 right?)

#bs.random:value_noise

[inputs] width: [int] height: [int] scale: [int] (instead of tile_size. i like the simple description tho, it's easier to understand that talking about frequency) with: Same as white noise

[outputs] bs:out random.value_noise (instead of bs:out random.noise)

Example Sadly the example cannot be run easily because it requires creating a function. I think this is something that could be added to the Examples datapack but this is something we can see later.

Note A good thing with the with keyword, is that in the futur we'll be able to add things such as octaves to generate more complex terrain, without introducing breaking changes

theogiraudet commented 4 weeks ago

By the way, it would be nice to have an alternative to #bs.random:choose that allows weighed values since Minecraft mainly works with that.