> For the complete documentation index, see [llms.txt](https://docs.nrnagents.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.nrnagents.ai/getting-started/model-initialization.md).

# Model Initialization

### Demo

In order to test out the SDK, users can create a demo agent that can start taking actions in their game! The purpose of the demo agent is to test out the entire flow of feeding in a state, taking actions, collecting data, and executing the actions in-game.

{% tabs %}
{% tab title="Javascript" %}

```javascript
const { AgentFactory } = require('nrn-agents');

const modelData = {
  config: {
    modelType: "neural-network",         // Type of model architecture
    inputDim: 5,                         // Number of features for the state
    neurons: [12, 6],                    // Number of neurons in each layer
    actionOrder: ["up", "down", "idle"]  // Order of action outputs
  }
}

const agent = AgentFactory.createDemoAgent(modelData)
```

{% endtab %}

{% tab title="C# - Unity" %}

```csharp
using NrnAgents.Agents;
using NrnAgents.MachineLearning;

ModelData modelData = new ()
{
    Config = new ()
    {
        ModelType = "neural-network",
        NFeatures = 5,
        Neurons = new List<int> () { 12, 6 },
        ActionMetadata = MetadataCreation.CreateActionMetadata(
            new AgentActions () { 
                ActionOrder = new ()  { "Up", "Down", "Idle" } 
            }
        )        
    }
};

DemoAgent Agent = AgentFactory.CreateDemoAgent(modelData);
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
Demo agents do not have the ability to learn
{% endhint %}

### Production

When initializing a model in-game, we need to use the following inputs:

* `architectureId`: A model architecture that has been registered
* `userId`: Unique identifier for a specific player
* `slotIdx`: Which model to use since each player may have multiple model slots

If NRN detects that there is already a model loaded for that user, it will load the trained model. In order to create a new randomly initialized model, developers can either input an unused `slotIdx` when creating the agent or call the `reset` method (currently only available in Javascript).

{% tabs %}
{% tab title="Javascript" %}

```javascript
const { AgentFactory } = require('nrn-agents');

const agent= AgentFactory.createAgent(
    "my-first-model", // architecture id
    "user-id",        // user id
    0,                // slot idx (default 0 if not provided)
)
await agent.initialize()

agent.reset() // To reset the agent
```

{% endtab %}

{% tab title="C# - Unity" %}

```csharp
using NrnAgents.Agents;

IAgentRL Agent = AgentFactory.CreateAgent<IAgentRL>(
    "reinforcement",  // learning algorithm type
    "my-first-model", // architecture id
    "user-id",        // user id
    0,                // slot idx
);
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.nrnagents.ai/getting-started/model-initialization.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
