Options
All
  • Public
  • Public/Protected
  • All
Menu
classdesc

The agent is what participates in a match and contains details on the files powering the agent, the process associated and many other details.

Reads in a file source for the code and copies the bot folder to a temporary directory in secure modes and creates an Agent for use in the MatchEngine and Match

This is a class that should not be broken. If something goes wrong, this should always throw a error. It is expected that agents are used knowing beforehand that the file given is validated

Hierarchy

  • EventEmitter
    • Agent

Index

Type aliases

Static GenerationMetaData

Static GenerationMetaData_CreateMatch

GenerationMetaData_CreateMatch: Array<{ botkey?: string; file: string; name: string }>

Agent generation meta data used by Dimension.createMatch

Static GenerationMetaData_FilesOnly

GenerationMetaData_FilesOnly: Array<string>

Agent Generation meta data with paths to files only

Static GenerationMetaData_Tournament

GenerationMetaData_Tournament: Array<{ botkey?: string; file: string; tournamentID: ID; version: number }>

Agent generation meta data used by tournaments

Static ID

ID: number

Agent ID. Always a non-negative integer and all agents in a match have IDs that are strictly increasing from 0

For example, in a 4 agent match, the ids are 0, 1, 2, 3.

Static LanguageSpecificOptions

LanguageSpecificOptions: {}

Language specic options mapping programming language to the agent options to use for that programing language. Used to customize options such as docker image, compile time limits etc. on a per language basis

Type declaration

Constructors

constructor

Properties

_buffer

_buffer: Array<string> = []

internal buffer to store stdout from an agent that has yet to be delimited / used

_clearTimer

_clearTimer: Function = noop

Clears out the timer associated with the agent during a match

_currentMovePromise

_currentMovePromise: Promise<void>

a promise that resolves when the Agent's current move in the Match is finished

_currentMoveReject

_currentMoveReject: Function

_currentMoveResolve

_currentMoveResolve: Function = noop

_logsize

_logsize: number = 0

Size of agent's logs so far

_trimmed

_trimmed: boolean = false

agentTimeStep

agentTimeStep: number = 0

A number that counts the number of times the agent has essentially interacted with the MatchEngine

Private allowedToSendCommands

allowedToSendCommands: boolean = true

whether agent is allowed to send commands. Used to help ignore extra output from agents

cmd

cmd: string = null

The command used to run the file

Private container

container: Container = null

Associated docker container running the agent

creationDate

creationDate: Date

Creation date of the agent

currentMoveCommands

currentMoveCommands: Array<string> = []

The commands collected so far for the current move

cwd

cwd: string

The current working directory of the source file. If in insecure mode, this is always a temporary directory that will get deleted later.

errorLogWriteStream

errorLogWriteStream: WriteStream = null

ext

ext: string

The extension of the file

file

file: string

The original file path provided

id

id: ID = 0

This agent's ID in a match. It is always a non-negative integer and agents in a match are always numbered 0, 1, 2, ...n where there are n agents.

Private log

log: Logger = new Logger()

logkey

logkey: string = null

Key used to retrieve the error logs of this agent

memoryWatchInterval

memoryWatchInterval: any = null

Interval that periodically watches the memory usage of the process associated with this agent

messages

messages: Array<string> = []

List of all messages written to this agent are directly pushed to here when in detached mode

name

name: string

Name of the agent

default

agent_[agent.id]

options

options: Options = deepCopy(Agent.OptionDefaults)

The agent's options

Private process

process: ChildProcess = null

The associated process running the Agent

src

src: string

The source path to the file that runs the agent

srcNoExt

srcNoExt: string

file without extension

status

status: Status = Agent.Status.UNINITIALIZED

Current status of the agent

tournamentID

tournamentID: ID = null

A tournmanet ID if Agent is generated from within a {@link Tournament}

version

version: number = 0

Agent version, used by tournament

Static defaultMaxListeners

defaultMaxListeners: number

Methods

_allowCommands

  • _allowCommands(): void

_compile

  • _compile(stderrWritestream: Writable, stdoutWritestream: Writable, engineOptions: EngineOptions): Promise<void>

_disallowCommands

  • _disallowCommands(): void

_finishMove

  • _finishMove(): Promise<void>

_getProcess

  • _getProcess(): ChildProcess

_install

  • _install(stderrWritestream: Writable, stdoutWritestream: Writable, engineOptions: EngineOptions): Promise<void>

_setTimeout

  • _setTimeout(fn: Function, delay: number, ...args: any[]): void

_setupMemoryWatcher

_setupMove

  • _setupMove(): void

_spawn

_spawnCompileProcess

  • _spawnCompileProcess(command: string, args: Array<string>): Promise<ChildProcess | ContainerExecData>

_spawnProcess

  • _spawnProcess(command: string, args: Array<string>): Promise<ChildProcess | ContainerExecData>

_storeProcess

  • _storeProcess(p: ChildProcess): void

_terminate

  • _terminate(): Promise<void>

addListener

  • addListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

containerSpawn

emit

  • emit(event: string | symbol, ...args: any[]): boolean
  • Parameters

    • event: string | symbol
    • Rest ...args: any[]

    Returns boolean

eventNames

  • eventNames(): Array<string | symbol>
  • Returns Array<string | symbol>

getAgentErrorLogFilename

  • getAgentErrorLogFilename(): string

getMaxListeners

  • getMaxListeners(): number

inputDestroyed

  • inputDestroyed(): boolean

isAllowedToSendCommands

  • isAllowedToSendCommands(): boolean

isTerminated

  • isTerminated(): boolean

listenerCount

  • listenerCount(type: string | symbol): number
  • Parameters

    • type: string | symbol

    Returns number

listeners

  • listeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

off

  • off(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

on

  • on(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

once

  • once(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

overMemory

  • overMemory(): void

prependListener

  • prependListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

prependOnceListener

  • prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

rawListeners

  • rawListeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

removeAllListeners

  • removeAllListeners(event?: string | symbol): this
  • Parameters

    • Optional event: string | symbol

    Returns this

removeListener

  • removeListener(event: string | symbol, listener: (...args: any[]) => void): this
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

resume

  • resume(): Promise<void>

setMaxListeners

  • setMaxListeners(n: number): this
  • Parameters

    • n: number

    Returns this

setupContainer

  • setupContainer(name: string, docker: Dockerode, engineOptions: EngineOptions): Promise<void>

stop

  • stop(): Promise<void>

timeout

  • timeout(): void

write

  • write(message: string, callback: (error: Error) => void): boolean

writeToErrorLog

  • writeToErrorLog(message: string): void

Static generateAgents

Static listenerCount

  • listenerCount(emitter: EventEmitter, event: string | symbol): number
  • deprecated

    since v4.0.0

    Parameters

    • emitter: EventEmitter
    • event: string | symbol

    Returns number

Object literals

streams

streams: object

Streams associated with the agent

err

err: null = null

in

in: null = null

out

out: null = null

Static OptionDefaults

OptionDefaults: object

Default Agent options

compileCommands

compileCommands: {}

Type declaration

detached

detached: false = false

id

id: null = null

image

image: string = "docker.io/stonezt2000/dimensions_langs"

logLimit

logLimit: number = 100000

loggingLevel

loggingLevel: INFO = Logger.LEVEL.INFO

maxCompileTime

maxCompileTime: number = 60000

maxInstallTime

maxInstallTime: number = 300000

name

name: null = null

runCommands

runCommands: {}

Type declaration

secureMode

secureMode: false = false

tournamentID

tournamentID: null = null

useCachedBotFile

useCachedBotFile: false = false

Generated using TypeDoc