Innaccurate Max Combinations
AbdulDridi opened this issue · comments
NFT-Art-Generator/src/app/home/home.component.ts
Lines 240 to 250 in f786d9d
This function makes 2 bad assumptions:
- 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);
}
- testing to confirm
Closed in b0ed7a3