Found this repo after a search for generating artwork using Rust and it seems what I am looking for. But I can't get it to work after trying a quick test.
Could not create weighted index, are any odds less than 0?
I tried looking in the code to see what made it not work, but I don't understand what your goal is with the different sets of attributes using "_"
and "_key"
as keys. It seems that when I run the code using the provided config.example.json
, that the so-called 'raw_keys' ("_"
) don't make it to the part where a WeightedIndex is made, for example:
"background": {
"_": {
"blue.png": 0.04,
"brown.png": 0.04,
"flesh.png": 0.05,
"green.png": 0.02
}
},
Then it crashes because it complains there are no values:
[src/metadata.rs:118] &weights = []
thread 'main' panicked at 'Could not create weighted index, are any odds less than 0?: NoItem', src/metadata.rs:121:10
(I added some dbg! statements, the crash happens when WeightedIndex::new() is called)
Could you explain what the idea is behind your code? Why the use of _
and _key
and _key:alchemist
?
EDIT: I see that the underscores basically preclude the names from the eventual metadata that is generated for the NFT, but it doesn't make much sense in the code for me.