> For the complete documentation index, see [llms.txt](https://docs.almightyalpacas.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.almightyalpacas.com/readme/obstacles.md).

# Obstacles

Some tracks are not perfect and feature damaged lanes, creating various obstacles that make parts of the track difficult to run. The types of obstacles include [<mark style="color:orange;">**Mud**</mark>](/readme/obstacles/mud.md), [<mark style="color:yellow;">**Sand**</mark>](/readme/obstacles/sand.md), and [<mark style="color:red;">**Rocks**</mark>](/readme/obstacles/rocks.md). Each obstacle type has its own [<mark style="color:red;">**Handling**</mark> ](/readme/alpaca-stats/handling.md)requirements, meaning alpacas with the same overall [<mark style="color:red;">**Handling**</mark> ](/readme/alpaca-stats/handling.md)stat may perform differently on these <mark style="color:red;">Obstacles</mark>. It's crucial to race often to learn which <mark style="color:red;">Obstacles</mark> suit your alpaca best.

***

## Obstacle Generation

Obstacles are generated using specific parameters to ensure variability and challenge in each race. Here are the key parameters:

* **MEAN\_OBSTACLE\_DISTANCE:** 500
* **OBSTACLE\_DISTANCE\_VARIANCE:** 40
* **MIN\_OBSTACLE\_LENGTH:** 25
* **MAX\_OBSTACLE\_LENGTH:** 30

### Generation Process

Obstacles are generated with the following steps:

1. **Determine Number of Obstacles:** The number of obstacles is based on the track length and the `MEAN_OBSTACLE_DISTANCE`.
2. **Calculate Mean Obstacle Distance:** This is adjusted by the number of available obstacles.
3. **Shuffle Obstacle Types:** Obstacle types are shuffled to ensure randomness.
4. **Place Obstacles:** Obstacles are placed at random positions within a variance range (`OBSTACLE_DISTANCE_VARIANCE`), ensuring they do not overlap and fit within the track length.

***

### Speed Resriction

**Speed Restriction Near Obstacles**

Alpacas must slow down near obstacles and turns, indicated by the **Speed Fraction** values, to navigate them safely

| Obstacle Type | Speed Fraction |
| ------------- | -------------- |
| Mud           | 45%            |
| Rocks         | 55%            |
| Sand          | 50%            |

\
\
**Slowing Down Near Turns**

Alpacas must also slow down near turns to navigate them safely. The speed reduction near turns is based on the turn radius:

| Degrees | Speed Fraction |
| ------- | -------------- |
| 10      | 30%            |
| 20      | 40%            |
| 30      | 50%            |
| 45      | 70%            |
| 60      | 80%            |

This slowing down happens within the **`LOOK_AHEAD_DISTANCE`.**\
Where ***`LOOK_AHEAD_DISTANCE = 24`*****.**
