thepeanutgalleryandco/create-and-mint-nft-collection

[FEATURE] Layer Maximum Repeatability Settings

thepeanutgalleryandco opened this issue · 3 comments

Summary

Add the ability to set the maximum number of times that a specific layer can repeat / be part of the collection.

Basic example

If I have a character layer with one item, hair layer with two items and glasses with three items.

Character:
main.png

Hair:
short.png
long.png

Glasses:
funky.png
square.png
oversized.png

Maximum layer repeatability: If I set my Glasses layer's maximum repeatability to 1, then only a single art work that gets generated will have one of the 3 glasses layer items. So with the layers, there would then be art work items generated:

  1. main.png + short.png
  2. main.png + long.png
  3. main.png + (short.png OR long.png) + (funky.png OR square.png OR oversized.png)

Motivation

Users would like to be able to force rarity on certain layers for their collections.

As written by arnaugm (Thank you very much for the work done here)

It can be configured at a layer configuration level with the option maxRepeatedTraits which expects a numeric value.

Example:

const layerConfigurations = [
  {
    growEditionSizeTo: 5,
    maxRepeatedTraits: 2,
    layersOrder: [
      { name: "Background" },
      { name: "Eyeball" },
      { name: "Eye color" },
      { name: "Iris" },
      { name: "Shine" },
      { name: "Bottom lid" },
      { name: "Top lid" },
    ],
  },
];

If for example this value is set to 2, whenever the art engine generates a new artwork that contains 3 or more traits already present in one of the pieces already created for the collection, this new piece will be discarded and a notification will be displayed in the console with the message:

Combination of traits excluded because of exclusion rules!
The creation of artworks will continue generating new combinations as usual.

This option will reduce the number of possible combinations and could be possible that the collection can not reach the requested number of elements. In this case increase the number of maximum repetitions or provide more traits in the layers that has less options to increase the probability of selecting different traits.

If the option is not defined the restriction is not applied.

I have introduced this functionality into my repo and have slightly modified the error that gets returned to the screen to "Combination of traits excluded because of maximum repeatability exclusion rule!"

Users can now make use of the maxRepeatedTraits configuration within their layer configuration set to allow the layers within that specific set to be generated only X number of times.

maxRepeatedTraits: 2