> For the complete documentation index, see [llms.txt](https://bonspiel-games.gitbook.io/cortex-unity-plugin/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bonspiel-games.gitbook.io/cortex-unity-plugin/training.md).

# Training

For simplicity, this training class only provides functionality for mental commands, largely ignoring facial expression functionality. Unless otherwise specified, all methods and events relate specifically to mental commands.

## Process

* &#x20;Load profile

note: it is possible to perform mental command training without first loading a profile, saving the training to a profile and loading it after.

```csharp
Cortex.profiles.Load("Jimmy");
```

* Start training

```csharp
Cortex.training.Start(MentalCommandNames.Push);
```

* Wait for Success or Failure

```csharp
Cortex.training.TrainingSucceeded += OnTrainingSucceeded;

void OnTrainingSucceeded(string headsetId)
{
    // do something
}
```

* Get the training threshold

```csharp
Cortex.training.GetTrainingThreshold();
Cortex.training.GetTrainingThresholdResult += OnTrainingThresholdResult;
```

* Accept or Reject the sample based on the threshold and grade

```csharp
void OnTrainingThresholdResult(TrainingThreshold trainingThreshold)
{
    if(trainingThreshold.lastTrainingScore > trainingThreshold.currentThreshold)
        Cortex.training.Accept(MentalCommandNames.Push);
    else
        Cortex.training.Reject(MentalCommandNames.Push);
}
```

* Wait for Accepted or Rejected

```csharp
Cortex.training.TrainingRejected += OnTrainingRejected;
```

* Repeat from step 2, alternating between neutral and action until satisfied (\~14+ samples)
* Save training to the profile for future use

```csharp
Cortex.training.SaveProfile("Jimmy", headsetId);
or
Cortex.profiles.Save("Jimmy", headsetId);
```

The incoming mental command stream will reflect training progress as it advances, including during a sample. There is no need to "apply" the training

### Target Session

The training handler will automatically target the most recently created session for ease of use, but it is a good idea to manually set the target session before starting to train.

## Mental Command Names

There are a limited number of action names that can be used when training mental commands. To simplify this, the first several available actions are provided as static string literals in the `MentalCommandNames` class. Generally the only ones you will ever need are neutral, push (action), and maybe a third one for a second action.

```csharp
public static class MentalCommandNames
{
    public const string Neutral = "neutral";
    public const string Push = "push";
    public const string Pull = "pull";
    public const string Lift = "lift";
    public const string Drop = "drop";
    public const string Left = "left";
    public const string Right = "right";
}
```
