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

# State & context

> Give decisions the player context they need.

`PIO.SetState` sets a named value included in the next decision's state snapshot. Better context means better decisions; a difficulty choice that cannot see the player's level is guessing.

```csharp Samples~/BasicIntegration/Assets/Scripts/GuideExamples.cs theme={null}
// State feeds the next decision's snapshot; set it before you ask.
PIO.SetState("std_level_index", 3);
PIO.SetState("std_xp_percent", 0.4f);
```

## The rules

* Accepted types: `string`, `int`, `long`, `float`, `double`, `bool`, or null. Anything else is warned and dropped.
* Visibility is immediate: `SetState` then `GetDecision` in the same frame sees the value.
* State is per-session and cleared on re-initialisation.
* Keys should match state definitions registered in the dashboard, such as `std_level_index`.

The SDK adds context of its own: each decision's snapshot includes per-action decision counters from earlier calls in the session.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.