> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://documentation.celestory.io/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# 🟥 Random path

# 🟥 Random path

${frame}[Video: anatomy of the Random path block](https://celestory-docs-videos.netlify.app/en/anatomie-bloc/randompath.html)

![Random path](https://celestory-docs-illustrations.netlify.app/en/Randompath_EN.svg)

The Random Path block picks one of the paths you've prepared in your story, at random. This is what creates surprise: a player who opens the same chest twice might find treasure the first time, and a trap the second.

Use it whenever you want the same spot in your story to not always play out the same way: an encounter, a reward, an obstacle...

## 📥 Entries

- in (Flow): Triggers the draw when the flow reaches this block.
- paths (Number): Number of possible paths from which the block will choose randomly (default: 2).
- shuffle (Boolean): If activated (True), the block memorizes the paths already taken (draw without replacement) and excludes them until all have been used at least once.

## 📤 Outings

- 1, 2, 3... (Flow): Numbered outputs corresponding to the possible paths (their number depends on the value of "paths"). Only one output is activated randomly.
- end (Flow): Output triggered only if "shuffle" is enabled and all paths have already been taken at least once.

## 💡 Example of use

Scenario: Opening a mysterious chest

1. The player finds a chest in a dark room.
1. A message is displayed: "You open the trunk carefully...".
1. The Random Path block is placed with number = 3 to simulate three possible outcomes.
1. The block randomly chooses an output:

- Exit 1: "The chest contains 100 gold coins!" (reward).
- Exit 2: "A trap is triggered! You lose 20 VP." (danger).
- Exit 3: "The trunk is empty..." (disappointment).

1. The flow continues to the event corresponding to the selected output.

## ⚙️ Technical Details

- Path management: Outputs are generated dynamically based on the value of "paths". If paths = 2, only outputs 1 and 2 will be available.
- "Shuffle" mode (draw without replacement): When this mode is activated, the block uses an internal list to follow the paths already taken. Once all paths are used, the "end" output is triggered.
- Reset: The block does not automatically reset its state between game sessions. For a complete new draw, disable then re-enable "shuffle" mode.

---

*Documented version: v1*