Package Exports
- arc-agents
Readme
Getting Started
This package is used for imitation learning and reinforcement learning in games.
Installation
To start using the package, you can install it as follows:
npm install arc-agentsBasic Setup
To get started using agents on the platform, you first need to register the agent. Only organization admins have this ability, and you will need to provide an api key:
const { Registry } = require("arc-agents")
Registry.setApiKey("admin-api-key")In order to use an agent, you need to set the gameId and apiKey
const { BaseAgent } = require("arc-agents")
BaseAgent.setGameId("game-id")
BaseAgent.setApiKey("training-api-key")Registration
Before creating an agent, we must register its architecture. Admins can also do this via the (dashboard)[https://arcagents.ai]
const registry = new Registry("game-id")
const modelType = "simple"
const architectureId = "my-first-model"
const numberOfStates = 10
const possibleActions = { direction: ["up", "down", "idle"] }
await registry.register(modelType, architectureId, numberOfStates, [], possibleActions)Create an Agent
Once you've registered a model architecture, you can use the architectureId to create a model
for any user:
const { FrequencyTable } = require("arc-agents")
const agent = new ImitationLearningAgent(architectureId, userId, slotIdx)
await agent.initialize()Take an Action
In order to take an action in the game, call the selectAction function, where the input is
a 2D array.
const action = agent.selectAction(state)Collect Data
To collect data, call the collect function. At a minimum, the data object must have the current
state and the action selected (as a one-hot encoded vector). Additionally, you can provide more
info which can be useful for reward shaping.
agent.collect({ state, action, info })