Jon-Becker / nft-generator-py

This tool allows users to generate sets of unique images and metadata using weighted layer collections.
MIT License
304 stars 126 forks source link

The random.choices weighting seems quite innacurate #3

Closed werksone closed 2 years ago

werksone commented 2 years ago

have been playing around with this all day and Im trying to deal with some really accurate trait weighting and unfortunately it seems like the randomness from the weighting is super inaccurate.

Any ideas what could be going on here? I have an example with 3 layers making 200 images and some of the lower end % traits should only be showing the image once but there are occasions where that trait will maybe show 4 - 5 times.

werksone commented 2 years ago
"layers": [
    {
    "name": "Background",
    "values": ["Gold", "Silver", "Stone", "Vines", "Wood"],
    "trait_path": "/Users/***/nft-generator-py/trait-layers/BG",
    "weights": [20, 20, 20, 20, 20]
    }

Another example of 200 images with the output of these being:

Gold: 44 Silver: 39 Stone: 37 Vines: 35 Wood: 45

This is really problematic for making some traits more rare than others

Jon-Becker commented 2 years ago

It's not exact, it's selecting with random % chance to get that trait. In the example you showed, it's mostly accurate since 20% of 200 is 40.