All layers have a 100% probability of being applied
Rarity Folders have a > 0% probability
This means:
When a layer % is less than 100%, we're artificially limiting the max combination ceiling - since not having the layer/item is also a valid combination
When a rarity folder has a 0% probability, it's not possible to select its images, so the program will be stuck in a loop trying to roll for a combination that doesn't exist (the one in which the item present in that layer exists in the 0% rarity folder)
The code should probably be (to be confirmed with unit tests):
getMaxImageCombinations() {
let itemsInLayers = [];
this.nftDirectory.layers.forEach((layer) => {
if (layer.rarity > 0) {
let itemsInLayer = layer.rarity == 1 ? 0 : 1;
layer.itemRarityFolders.forEach((rarityFolder) => {
if (rarityFolder.rarity > 0) {
itemsInLayer += rarityFolder.items.size;
}
})
itemsInLayers.push(itemsInLayer);
}
})
return itemsInLayers.reduce((total, num) => total * num);
}
https://github.com/AppsusUK/NFT-Art-Generator/blob/f786d9db53cc9fe35901b6dd9ad6ba79e38c431f/src/app/home/home.component.ts#L240-L250
This function makes 2 bad assumptions:
This means:
The code should probably be (to be confirmed with unit tests):