UNPKG

arc-agents

Version:

A library for creating and deploying gaming agents at scale

51 lines (39 loc) 1.18 kB
const ImitationLearningAgent = require('./imitation-learning-agent') const ReinforcementLearningAgent = require('./reinforcement-learning-agent') const DemoAgent = require('./demo-agent') const AgentVars = require('./agent-vars') class AgentFactory { static getApiKey() { return AgentVars.apiKey } static getBackendUrl() { return AgentVars.backend } static overrideBackendUrl(newBackend) { AgentVars.backend = newBackend } static setGameId(gameId) { AgentVars.gameId = gameId } static setApiKey(apiKey) { AgentVars.apiKey = apiKey } static setAuthorization(authorization) { AgentVars.authorization = authorization } static createAgent(agentType, ...args) { const agentMapping = { 'reinforcement': ReinforcementLearningAgent, 'imitation': ImitationLearningAgent }; const AgentClass = agentMapping[agentType] if (!AgentClass) { throw new Error(`Unknown agent type: ${agentType}`) } return new AgentClass(...args) } static createDemoAgent(...args) { return new DemoAgent(...args) } } module.exports = AgentFactory