> ## Documentation Index
> Fetch the complete documentation index at: https://docs.forgegames.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Rolling

> Randomize item generation using roll numerators for scalable probabilities

## What is Rolling?

Rolling is the process of generating randomized items or loot based on their defined properties. In Forge, rolling uses a **roll numerator** system, which ensures scalable and dynamic probabilities as you add or adjust items or classifications in your game.

### How Roll Numerators Work

Each item or classifier option is assigned a **roll numerator**, representing its weight in the roll. The system calculates the **roll denominator** as the sum of all numerators for the available options. An item's or group's probability is calculated as:

Probability = (Roll Numerator) / (Roll Denominator)

This system ensures that probabilities scale dynamically when you add or modify items or classifier options, maintaining balance without recalibration.

## Classifier Options and Group-Level Control

In addition to assigning numerators to individual items, you can also assign numerators to **classifier options**. This allows you to manage probabilities at a group level. For example, you can control how often items of a particular **rarity** drop without defining individual item probabilities.

### Example Configuration

#### Classifier: Rarity

| Classifier Option | Roll Numerator | Probability       |
| ----------------- | -------------- | ----------------- |
| `Common`          | 70             | 70 / 120 = 58.33% |
| `Uncommon`        | 30             | 30 / 120 = 25.00% |
| `Rare`            | 15             | 15 / 120 = 12.50% |
| `Legendary`       | 5              | 5 / 120 = 4.17%   |

**Roll Denominator**: ( 70 + 30 + 15 + 5 = 120 )\
This configuration controls how often items from each rarity classification are rolled.

#### Combining Classifier Options and Items

You can assign numerators to both classifier options and individual items for more granular control.

**Example: Rarity with Items**

| Rarity     | Item     | Roll Numerator | Probability       |
| ---------- | -------- | -------------- | ----------------- |
| `Common`   | `Sword`  | 50             | 50 / 100 = 50.00% |
|            | `Shield` | 50             | 50 / 100 = 50.00% |
| `Uncommon` | `Potion` | 30             | 30 / 30 = 100.00% |

**Roll Denominator for Rarity**: ( 70 + 30 = 100 )\
**Roll Denominator for Common Items**: ( 50 + 50 = 100 )

If a Common rarity is rolled, there’s an equal 50% chance of getting a Sword or a Shield.

<Tip>
  Using classifier options and item-level numerators together allows you to
  define probabilities at both the group and item level, providing maximum
  flexibility for your loot system.
</Tip>

***

## Practical Applications

* **Group-Level Control**: Use classifier options like **rarity** to control probabilities across a category of items.
* **Granular Probabilities**: Assign numerators to individual items for precise control within a group.
* **Dynamic Scaling**: Easily add new classifier options or items without recalibrating the entire loot system.

***

## Best Practices

1. **Combine Group and Item Control**: Use classifier options for high-level probability control and item numerators for fine-tuning within groups.
2. **Test for Balance**: Ensure your roll numerators reflect desired rarity distributions and are balanced for gameplay.
3. **Use Intuitive Values**: Keep numerators simple and consistent (e.g., 10, 50, 100) to make scaling straightforward.

***

## Example Use Case: Treasure Chest Drops

Imagine a treasure chest with the following configuration:

#### Classifier: Rarity

| Classifier Option | Roll Numerator | Probability       |
| ----------------- | -------------- | ----------------- |
| `Common`          | 70             | 70 / 170 = 41.18% |
| `Uncommon`        | 50             | 50 / 170 = 29.41% |
| `Rare`            | 30             | 30 / 170 = 17.65% |
| `Legendary`       | 20             | 20 / 170 = 11.76% |

#### Items within Rarities

| Rarity      | Item         | Roll Numerator | Probability         |
| ----------- | ------------ | -------------- | ------------------- |
| `Common`    | `Gold Coins` | 50             | 50 / 100 = 50.00%   |
|             | `Shield`     | 50             | 50 / 100 = 50.00%   |
| `Legendary` | `Excalibur`  | 100            | 100 / 100 = 100.00% |

**Roll Denominator for Rarity**: ( 70 + 50 + 30 + 20 = 170 )\
**Roll Denominator for Common Items**: ( 50 + 50 = 100 )

This configuration ensures balanced probabilities for both rarities and items within each rarity.

***

By using roll numerators for classifier options and items, Forge enables dynamic, scalable, and flexible probability systems that adapt to your game’s evolving needs.
