Basic Integration
As mentioned in the setup section, game studios will be required to create 2 files in order for the NRN Agent to "understand" the game world, and for the game world to "understand" the NRN Agent output. The NRN team will provide partner game studios with template files for Javascript, Unity, and Unreal.

After instantiating the NRN Agent, the basic flow for integration is as follows:
Convert the game world into an state space that the NRN model can use
Human Controlled
Update human inputs
Convert executed inputs to an action that the NRN model can understand
Add the state and action pair to the dataset
NRN Agent Controlled
Perform inference to select the action
Convert the selected action to an input that the game can understand
Either send data to the trainer platform or train directly in-game
Below we show how to initialize the model and use it at the game manager level:
class Game {
// Instantiate agent
constructor(agentInputs) {
this.agent = AgentFactory.createAgent(...agentInputs);
}
// Game loop update
update() {
// Get the state space for the model
const state = getStateSpace(this);
if (this.human) {
// If human is controlling, then update their inputs
this.inputs.p1.update();
// Convert the inputs into something the NRN agent can understand
const action = getActionOneHot(this.inputs.p1);
// Add the observed state and action to the dataset
this.agent.collect({ state, action });
}
else {
// If NRN agent is controlling, then perform inference
const agentAction = this.agent.selectAction(state);
// Execute the action in-game
convertActionToGame(agentAction);
}
}
}
Then at the end of the game, you can send the data you collected to the trainer platform as follows:
await agent.uploadData();
OR
If you have the API access to train in-game, then you can directly train within the game loop as follows:
await agent.train(model.getTrainingData(), trainingConfiguration);
Last updated