Skip to content

Making DNA truly unique #108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ const writeMetaData = (_data) => {
};

// holds which dna has already been used during generation
let dnaListByRarity = {};
let dnaListByRarity = [];
// holds metadata for all NFTs
let metadataList = [];
// Create generative art by using the canvas api
Expand All @@ -181,9 +181,9 @@ const startCreating = async () => {
writeMetaData("");

// prepare dnaList object
rarityWeights.forEach((rarityWeight) => {
dnaListByRarity[rarityWeight.value] = [];
});
// rarityWeights.forEach((rarityWeight) => {
// dnaListByRarity[rarityWeight.value] = [];
// });

// create NFTs from startEditionFrom to editionSize
let editionCount = startEditionFrom;
Expand All @@ -198,7 +198,7 @@ const startCreating = async () => {
// calculate the NFT dna by getting a random part for each layer/feature
// based on the ones available for the given rarity to use during generation
let newDna = createDna(layers, rarity);
while (!isDnaUnique(dnaListByRarity[rarity], newDna)) {
while (!isDnaUnique(dnaListByRarity, newDna)) {
// recalculate dna as this has been used before.
console.log('found duplicate DNA ' + newDna.join('-') + ', recalculate...');
newDna = createDna(layers, rarity);
Expand Down Expand Up @@ -239,7 +239,7 @@ const startCreating = async () => {
console.log('- edition ' + editionCount + ' created.');
console.log();
});
dnaListByRarity[rarity].push(newDna);
dnaListByRarity.push(newDna);
editionCount++;
}
writeMetaData(JSON.stringify(metadataList));
Expand Down