# finalVariants
Source: https://docs.maelstrom-ai.co/0.2/reference/engine/functions/finalvariants/
Documentation revision: 89a8f5e9d10cedcf0b30376d7846113f06f26120
SDK manifests in this build: @maelstrom-co/react@0.2.1, @maelstrom-co/client@0.2.1, @maelstrom-co/connectors@0.2.1, @maelstrom-co/protocol@0.2.1, @maelstrom-co/engine@0.2.1
These docs follow this source revision. Manifest versions do not prove release compatibility; verify the installed package exports before using an API.

> **finalVariants**(`instances`, `actions`, `vessels`): `Result`<`ReadonlyMap`<`InstanceId`, `VariantName`\>, [`SimulationError`](https://docs.maelstrom-ai.co/0.2/reference/engine/type-aliases/simulationerror/)\>

Defined in: packages/engine/src/lib/response/execution-plan/final-variants.ts:53

Replays an Execution Plan’s actions in order and returns the variant each instance ends in.

An action with `transitionsTo` moves its instance to that variant, and each later action resolves against the variant reached so far. Any other action leaves the variant unchanged, as do instances no action targets.

Where the Engine skips an action it cannot resolve and carries on, this replay stops at the first such action and returns a [SimulationError](https://docs.maelstrom-ai.co/0.2/reference/engine/type-aliases/simulationerror/), so a planner can reject or repair the plan before handing it over.

## Parameters

### instances

readonly `Readonly`<`Pick`<`VesselInstanceSnapshot`, `"instanceId"` | `"vesselId"` | `"variant"`\>>\[\]

The instances and their variants before the plan runs.

### actions

readonly `Readonly`<`Pick`<`ActionExecution`, `"instanceId"` | `"action"`\>>\[\]

The plan’s actions, in execution order.

### vessels

readonly `object`\[\]

The catalog the instances belong to.

## Returns

`Result`<`ReadonlyMap`<`InstanceId`, `VariantName`\>, [`SimulationError`](https://docs.maelstrom-ai.co/0.2/reference/engine/type-aliases/simulationerror/)\>
