Refactored DNA Generator to ensure no duplicate DNA

pull/24/head
Torrin Leonard 2021-11-19 20:30:21 -05:00
rodzic 74852ad837
commit 06e70671a0
4 zmienionych plików z 52 dodań i 43 usunięć

Wyświetl plik

@ -288,33 +288,43 @@ def generateNFT_DNA():
possibleNums = list(range(1, numChild + 1))
listOptionVariant.append(possibleNums)
def createDNARandom():
ab = []
for x in range(config.maxNFTs):
dnaStrList = []
for i in listOptionVariant:
randomVariantNum = random.choices(i, k = 1)
str1 = ''.join(str(e) for e in randomVariantNum)
dnaStrList.append(str1)
if dnaStrList not in DNAList:
ab.append(dnaStrList)
else:
createDNARandom()
return ab
dnaSplitList = createDNARandom()
for i in dnaSplitList:
dnaStr = ""
for j in i:
num = "-" + str(j)
dnaStr += num
dnaStrList = []
for i in listOptionVariant:
randomVariantNum = random.choices(i, k = 1)
str1 = ''.join(str(e) for e in randomVariantNum)
dnaStrList.append(str1)
for i in dnaStrList:
for j in i:
num = "-" + str(j)
dnaStr += num
dna = ''.join(dnaStr.split('-', 1))
DNAList.append(dna)
return str(dna)
for i in range(config.maxNFTs):
DNAList.append(createDNARandom())
def anydup(DNAList):
dups = None
seen = set()
for x in DNAList:
if x in seen:
DNAList.remove(x)
DNAList.append(createDNARandom())
dups = True
anydup(DNAList)
else:
dups = False
seen.add(x)
return dups
anydup(DNAList)
possibleCombinations = config.maxNFTs

Wyświetl plik

@ -12,28 +12,18 @@ sys.modules.values()
from src.main import config
importlib.reload(config)
listBatchFolder = os.listdir(config.batch_save_path)
numInBatchFolder = len(listBatchFolder)
removeList = [".gitignore", ".DS_Store", "Script_Ignore_Folder"]
batchList = [x for x in listBatchFolder if (x not in removeList)]
def checkIfBatchDup(i):
file_name = os.path.join(config.batch_save_path, i)
DataDictionary = json.load(open(file_name))
nftsInBatch = DataDictionary["NFTs_in_Batch"]
hierarchy = DataDictionary["hierarchy"]
DNAList = DataDictionary["BatchDNAList"]
def countDups(thelist):
numOfDupDNA = 0
seen = set()
for x in thelist:
if x in seen: numOfDupDNA += 1
if x in seen:
print(x)
numOfDupDNA += 1
seen.add(x)
return numOfDupDNA
@ -41,8 +31,15 @@ def checkIfBatchDup(i):
return duplicates
def checkDups():
listBatchFolder = os.listdir(config.batch_save_path)
numInBatchFolder = len(listBatchFolder)
for i in batchList:
print("\nThis is the duplication result for " + i + ":")
print(checkIfBatchDup(i))
print("\n")
removeList = [".gitignore", ".DS_Store", "Script_Ignore_Folder"]
batchList = [x for x in listBatchFolder if (x not in removeList)]
for i in batchList:
print( "\n" + i + " has " + str(checkIfBatchDup(i)) + " duplicate NFT DNA.\n")
if __name__ == '__main__':
checkDups()

Wyświetl plik

@ -1,7 +1,7 @@
import platform
# NFT configurations:
nftsPerBatch = 100000 # Number of NFTs per batch
nftsPerBatch = 100 # Number of NFTs per batch
renderBatch = 1 # The batch number to render in PNG-Generator
imageName = 'TestImage' # The name of the NFT image produces by PNG-Generator
imageFileFormat = '' # Dictate the image extension when Blender renders the images
@ -16,7 +16,7 @@ save_path_windows = r''
# Example mac: /Users/Path/to/Blend_My_NFTs
# Example windows: C:\Users\Path\to\Blend_My_NFTs
maxNFTs = 1000000 # The maximum number of NFTs you want to generate - does not work with enable3DModels set to True.
maxNFTs = 200 # The maximum number of NFTs you want to generate - does not work with enable3DModels set to True.
# Set to True to generate images or 3D models depending on your settings below when main.py is run in Blender.
# Only works if you have already generated NFTRecord.json and all batches.

Wyświetl plik

@ -8,8 +8,9 @@ dir = os.path.dirname(bpy.data.filepath)
sys.path.append(dir)
sys.modules.values()
from src.main import config
from src.main import config, DuplicateChecker
importlib.reload(config)
importlib.reload(DuplicateChecker)
from src.Model_Generators import Model_Generator
from src.Image_Generators import Batch_Sorter, DNA_Generator, Image_Generator, RenderTest, Preview
@ -28,6 +29,7 @@ if not config.runPreview and not config.renderImage:
if not config.enable3DModels:
DNA_Generator.send_To_Record_JSON()
Batch_Sorter.makeBatches()
DuplicateChecker.checkDups()
if config.runPreview:
Preview.printImportant()