# Rules

{% embed url="<https://www.youtube.com/watch?v=ZsRpGzZoZug>" %}
In this video, Pablo will show you how to use rules for your collection. Continue to [Session 7: Adding Custom Tokens](https://docs.bueno.art/generator/curating-your-collection/custom-tokens) to learn about saving and creating custom tokens.&#x20;
{% endembed %}

While creating each of the traits in your collection, you may find that some traits do not mix well with others. In these cases, you want to create rules within the **rules** tab under **manage**.

Rules are great for simple, straightforward pairing requirements. We suggest rules for when you just need a few attributes to behave a particular way together. Before creating a complex set of rules, you should first consider if [templates](https://docs.bueno.art/generator/curating-your-collection/templates) or [tags](https://docs.bueno.art/generator/curating-your-collection/tags) suit your needs better.

With that said, let’s take a deep dive into rules! For our examples, we will once again work with our Bueno Gente.

### Doesn’t Mix With

Let’s begin with the most straightforward rule. **Doesn’t mix with** prevents a selected trait from ever appearing with another selected trait. This rule is **bidirectional** - that means it works both ways!

#### Example:

**Problem:** In the Bueno Gente collection, we have a body color and a background color that are a little too similar - Purple and Blurple.

![](https://3197803409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fo9IBs7DeWK0IjMWTqEXb%2Fuploads%2F01MsciPwz9E4XyCib8Ju%2FCleanShot%202022-04-28%20at%2016.28.09%402x.png?alt=media\&token=e90c455e-8632-4805-aaf2-08b3c117c935)

To make sure our tokens look good and have color contrast, we don’t want the purple bodies to ever mix with the blurple background. Time to make a rule!

**Rule:** *Purple Body* **doesn’t mix with** *Blurple Background*.

<figure><img src="https://3197803409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fo9IBs7DeWK0IjMWTqEXb%2Fuploads%2FUQFlOfU2KRBJOMgkyTzO%2FCleanShot%202022-09-06%20at%2013.54.10%402x.png?alt=media&#x26;token=52d68c50-cbbc-433c-94ad-68d1bc6fe1ac" alt=""><figcaption></figcaption></figure>

**Result:** Whenever *Blurple Background* appears in a token, *Purple Body* will never appear in that token.

<figure><img src="https://3197803409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fo9IBs7DeWK0IjMWTqEXb%2Fuploads%2FzZqvUp9LeP1GwOZmMTQz%2FCleanShot%202022-09-06%20at%2013.58.03%402x.png?alt=media&#x26;token=e30b2618-b421-4b6f-ba36-79d517687796" alt=""><figcaption></figcaption></figure>

Likewise, whenever *Purple Body* appears, *Blurple Background* will never appear.

<figure><img src="https://3197803409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fo9IBs7DeWK0IjMWTqEXb%2Fuploads%2FW7JGTSEa65gQXBDLjLbH%2FCleanShot%202022-09-06%20at%2014.00.09%402x.png?alt=media&#x26;token=3efd6130-c595-4b35-8697-a6d299312ffd" alt=""><figcaption></figcaption></figure>

### Only Mixes With

Our next rule is a little more tricky. **Only mixes with** works when you would like a selected trait only to appear when another selected trait appears.

The only mixes with rule is **unidirectional,** and only works one way - from left to right! So, just because trait *x* only mixes with trait *y*, that doesn’t mean that *y* only mixes with trait *x*. Any other trait options in your trait pool can still mix with *y*.

#### Example:

**Problem:** Let’s say we still aren’t satisfied with the color contrast between the purple body and most of the other background colors. So, we’d like to see the purple bodies only with green or yellow backgrounds so they *really* pop.

**Rule:** *Purple Body* **only mixes** **with** *Yellow Background* and *Green Background.*

<figure><img src="https://3197803409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fo9IBs7DeWK0IjMWTqEXb%2Fuploads%2FRnJzqE5CYW9Zo366fNSY%2FCleanShot%202022-09-06%20at%2014.01.30%402x.png?alt=media&#x26;token=7b227aca-d2bb-4848-ba58-49fb45c6d005" alt=""><figcaption></figcaption></figure>

**Result:** Whenever *Purple Body* appears in a token, it will be paired with *Green Background* or *Yellow Background*.

<figure><img src="https://3197803409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fo9IBs7DeWK0IjMWTqEXb%2Fuploads%2FCWQcmTgXUSERmvJtm9Od%2FCleanShot%202022-09-06%20at%2014.02.23%402x.png?alt=media&#x26;token=cce31d57-03af-4cf4-a4cf-9845477a9a0b" alt=""><figcaption></figcaption></figure>

However, whenever *Green Background* appears in a token, it doesn’t always need to be paired with *Purple Body*. It can still appear with any color body! The same goes with *Yellow*.

<figure><img src="https://3197803409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fo9IBs7DeWK0IjMWTqEXb%2Fuploads%2FdLbGY76qlaWBUIT9GiJF%2FCleanShot%202022-09-06%20at%2014.03.59%402x.png?alt=media&#x26;token=e8dce519-f1ed-4409-aab7-d3802076073c" alt=""><figcaption></figcaption></figure>

### Always Pairs With

**Always pairs with** is a stricter version of **only mixes with**. This rule ensures that traits **always** appear together, and **never** separate. You can think of it as kind of the opposite of our **doesn’t mix with** rule.

Since the **always pairs with** rule works both ways, it can be used to group multiple traits from different attributes together. For example:

* Trait *x* always pairs with trait *y*
* Trait *y* always pairs with trait *z*
* Traits *x*, *y* & *z* will always appear together

#### Example:

**Problem:** As we are working with our Bueno Gente tokens, we finally decide that we want something like our previous rule, only *more strict*. We only want to see green and yellow backgrounds when we have a purple body in a token.

**Rule:** *Purple Body* **always pairs with** *Yellow Background* and *Green Background.*

<figure><img src="https://3197803409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fo9IBs7DeWK0IjMWTqEXb%2Fuploads%2FRMFjAPShpkbfjZIldzgh%2FCleanShot%202022-09-06%20at%2014.05.15%402x.png?alt=media&#x26;token=9d401809-9c56-467a-85df-2687ce4c2e75" alt=""><figcaption></figcaption></figure>

**Result:** Whenever a purple body appears, the background will either be yellow or green, and nothing else.

<figure><img src="https://3197803409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fo9IBs7DeWK0IjMWTqEXb%2Fuploads%2FuDt48feNpVvuQHNa4YOr%2FCleanShot%202022-09-06%20at%2014.06.17%402x.png?alt=media&#x26;token=7c8de5c3-9031-4e95-a8f2-001b67da0e12" alt=""><figcaption></figcaption></figure>

Likewise, No other body colors besides purple will be paired with yellow or green backgrounds.

<figure><img src="https://3197803409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fo9IBs7DeWK0IjMWTqEXb%2Fuploads%2FLYSJapPduR0WCZk5HC43%2FCleanShot%202022-09-06%20at%2014.08.04%402x.png?alt=media&#x26;token=09b7dc95-99f8-43c2-9eb4-b7e568c1e1f4" alt=""><figcaption></figcaption></figure>

#### Pairing and Trait Probability

If a trait is paired to another, then the chance of it getting picked is equal to the rarity of either traits getting picked. As a result, a trait that has a low rarity % (very rare) may become more common (less rare) if it has been paired with a trait of higher rarity.

This is basic probability at work when there are two events that are not mutually exclusive. This means that the overall rarity of your paired traits in your token set equals the probability of both traits combined (Trait A + Trait B) minus the probability of both showing up together (Trait A x Trait B).

If this seems a bit complicated, we can brush up on probability together!

#### **Example**

Let’s say we set *Purple Body* rarity at 2% (rare), and *Yellow Background* rarity at 20% (common). Then, we tell Bueno to **always pair** those 2 traits.

**Problem:** Out of a token set of 100, about how many tokens will have both traits? We can estimate by using — *you guessed it —* math!

We will be using the simple formula (A+B) - (AxB) = overall rarity

.02 + .20 = .22

.02 x .20 = .004

.22-.004 = .216

.216 = 21.6%

**Solution**: The overall rarity of the traits is 21.6%, so we should have about 21 or 22 tokens with these paired traits in a set of 100 total tokens.

#### **Note on Fixed Quantity Trait Pairings**

If any of the traits has a **fixed quantity**, then paired traits will be limited to the **lowest** fixed value.

### Appears With At Least One (Beta)

Our latest rule gives you the power to make sure that your tokens have at least one asset. This is useful when you want to vary the number of assets that show up in your tokens, but want to make sure none of your tokens end up with zero assets. This rule is great for collections with many different attribute groups to create additional token variation.

#### **Example:**&#x20;

**Problem:** We want to vary attribute distribution across our token set. We decide that we want tokens to have hair sometimes, clothes sometimes and both attributes sometimes. However, we **never** want a token to be completely nude (no clothes, no hair).&#x20;

<figure><img src="https://3197803409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fo9IBs7DeWK0IjMWTqEXb%2Fuploads%2FGsoNT9gvjekpCHrRmSdD%2Fatleastone.png?alt=media&#x26;token=1c367ac8-4e88-47ec-8be9-9122464aa6a5" alt=""><figcaption></figcaption></figure>

To get our desired outcome, we start by setting the attribute rarity of *Hair* and Clothes down to 50%. For the sake of this example, we will limit all *Body* options to *Blue*.&#x20;

<div><figure><img src="https://3197803409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fo9IBs7DeWK0IjMWTqEXb%2Fuploads%2FNlDeCD7j61vdvf4NGznn%2FCleanShot%202022-09-06%20at%2015.11.48%402x.png?alt=media&#x26;token=eed16666-3e80-4448-bc45-8ac13d477019" alt=""><figcaption></figcaption></figure> <figure><img src="https://3197803409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fo9IBs7DeWK0IjMWTqEXb%2Fuploads%2FVbeonNcaFNoxuHxCoMqb%2FCleanShot%202022-09-06%20at%2015.12.08%402x.png?alt=media&#x26;token=a9ca99ed-0ceb-4de7-9e0f-0e21e5b94d6b" alt=""><figcaption></figcaption></figure></div>

While some tokens are rendering correctly, we see that many of our tokens are totally nude, lacking both hair and clothes. Uh oh!&#x20;

<figure><img src="https://3197803409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fo9IBs7DeWK0IjMWTqEXb%2Fuploads%2F1dSCjEGk5Wn9ZZdmRJFk%2FCleanShot%202022-09-06%20at%2015.23.17%402x.png?alt=media&#x26;token=22eac705-374d-423d-8cc9-694937e001f0" alt=""><figcaption></figcaption></figure>

Setting our attributes' rarities below 100% means that the traits in those attributes won't always show up in a token when we hit generate. We can now correct the problem with a rule!

**Solution:**&#x20;

We will set up an **always appears with** rule so that our *Body* always appears with at least one *Hair* or *Clothes* trai&#x74;*.*

<figure><img src="https://3197803409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fo9IBs7DeWK0IjMWTqEXb%2Fuploads%2FVSvt8jEfVp7tWlAbc1sI%2FCleanShot%202022-09-06%20at%2014.45.27%402x.png?alt=media&#x26;token=48366f0c-cfc6-4ddc-bfa9-6f42f4c59a88" alt=""><figcaption></figcaption></figure>

Now, when we generate, we will no longer see those nude tokens.&#x20;

<figure><img src="https://3197803409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fo9IBs7DeWK0IjMWTqEXb%2Fuploads%2FF3o9Hmbn0Nsi4hlNqNXa%2FCleanShot%202022-09-06%20at%2015.21.27%402x.png?alt=media&#x26;token=da9e99d1-fcce-4686-a691-a3e485b902ad" alt=""><figcaption></figcaption></figure>

## Troubleshooting Rules

If your tokens are failing to generate or you notice rules aren’t behaving then we have some things you can do to help isolate the problem.

#### First, check your rules.

You can use our rule analysis (**Manage** > **Rules** > **Analyze Rules**) tool to make sure you don’t have any conflicting rules. It’s very easy to create rules that conflict, but we try our best to find these for you!

You can also try removing rules one at a time to find which one is causing the generation to fail. You can always re-add it after.

#### Check your templates.

If you’re using fixed trait or template quantities then make sure you have allocated enough traits. A template will not be used if it cannot satisfy **always pairs with** rules.

#### Check trait rarity.

Trait rarity also plays an important role. If your traits are too rare, or you have the overall attribute rarity set less than 100%, it’s possible the generator will never pick your traits.

#### Getting more help

If you’re still stuck, please reach out to our support channel with a link to your collection and a description of what’s going wrong.
