Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Gymie

WebSocket client that consumes an API wrapping OpenAI Gym or gym-like environments such as Gym Retro or Unity ML-Agents. Currently the best server is its counterpart Gymie-Server 😉

Hierarchy

  • Gymie

Index

Constructors

constructor

Properties

requester

requester: Requester<Command, string>

wsClient

wsClient: WebSocketClient = null

wsConn

wsConn: connection = null

Methods

close

  • close(reasonCode?: number, description?: string): void
  • Closes the connection with the server.

    example
    gymie.close(1000, 'Done training')

    Parameters

    • Optional reasonCode: number
    • Optional description: string

    Returns void

connect

  • connect(wsApi: string): Promise<void>
  • Asynchronous method that establishes connection with the server.

    throws

    ConnectFailed

    example
    try {
      await gymie.connect('ws://0.0.0.0:5000')
    } catch(err) {
      // err instanceof ConnectFailed
    }

    Parameters

    • wsApi: string

      Host and port to connect to.

    Returns Promise<void>

make

  • make<O, A>(envId: string, seed?: number): Promise<Env<O, A>>
  • Instantiates an environment, returning a promise wrapping and instance of Env

    throws

    NoConnected

    example
    try {
      const env = await gymie.make<Continuous, Discrete>('LunarLander-v2')
    } catch (err) {
      // err instanceof NoConnected
    }

    Type parameters

    Parameters

    • envId: string
    • Optional seed: number

    Returns Promise<Env<O, A>>

onClose

  • onClose(code: number, desc: string): void

onError

  • onError(err: Error): void

onMessage

  • onMessage(message: IMessage): void
  • Callback function for message event. Resolves the promise of the incoming message. See WebSocketConnection.onmessage

    Parameters

    • message: IMessage

      Message received from the server (plus type).

    Returns void

sender

Generated using TypeDoc