# Type Configuration

The types used by [HFSM2](https://hfsm.dev/) can be configured using parameterized `hfsm2::MachineT<hfsm2::Config>` structure in place of default-configured `hfsm2::Machine`, e.g.:

`using M = hfsm2::MachineT<`\
&#x20;             `hfsm2::Config`\
&#x20;                 `::ContextT<Empty>`\
&#x20;                 `::RandomT<hfsm2::XoShiRo128Plus>`\
&#x20;         `>;`

(from [test\_debug.cpp](https://github.com/andrew-gresyk/HFSM2/blob/master/test/test_debug.cpp)).

Once `hfsm2::Config` is fully declared, it needs to be passed as a template argument into `hfsm2::MachineT<>` to define configured [HFSM2](https://hfsm.dev/) parent struct containing all derivative types used in client code.

### `hfsm2::Config` customization points:

| Feature Define                | Type                    | Used In                                                                                                                                                                              | Default                                          |
| ----------------------------- | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------ |
|                               | `ContextT<T>`           | <p><code>Context& Control::context()</code></p><p>(see <a href="https://doc.hfsm.dev/user-guide/configuration/context">Context</a>)</p>                                              | `EmptyContext`                                   |
| `HFSM2_ENABLE_UTILITY_THEORY` | `RankT<T>`              | `Rank State::rank()`                                                                                                                                                                 | `int8_t`                                         |
| `HFSM2_ENABLE_UTILITY_THEORY` | `UtilityT<T>`           | `Utility State::utility()`                                                                                                                                                           | `float`                                          |
| `HFSM2_ENABLE_UTILITY_THEORY` | `RandomT<T>`            | Used internally by `randomize()` transition and `Random` region                                                                                                                      | `RandomT<float>`                                 |
|                               | `SubstitutionLimitN<N>` | Maximum number of times `State::entryGuard()`methods are allowed to substitute the transition into their class for a transition into another one during the single `*Root::update()` | `4`                                              |
| `HFSM2_ENABLE_PLANS`          | `TaskCapacityN<N>`      | Total number of tasks across all plans in an FSM                                                                                                                                     | 2x Number of Sub-States of All Composite Regions |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doc.hfsm.dev/user-guide/configuration/type-configuration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
