How openai/universe works
Universe exposes interactive applications as Gym environments: an agent steps through a client environment, which sends keyboard and mouse actions to a containerized remote and returns screen observations, rewards, and episode status. Environment registration and wrappers configure the agent-facing interface; vectorization and diagnostics support scaled runs. VNC carries display and input traffic, while a WebSocket reward channel carries reward and control messages. The README and source index establish the major boundaries; several internal dispatch details are not shown in the excerpts, so links to those are omitted or marked unverified.
Main entry points: vnc_env.py VNC environment client · wrappers Gym wrappers · rewarder_session.py Reward session · vnc_client.py VNC protocol client
Components 26
Agent interface
- Environment registry
universe/__init__.py - Gym wrappers
universe/wrappers - Vector environments
universe/vectorized/core.py - Multiprocess vectorizer
universe/vectorized/multiprocessing_env.py - Diagnostics
universe/envs/diagnostics.py
Environment runtime
- VNC environment client
universe/envs/vnc_env.py - Game and browser environments
universe/envs/vnc_core_env/vnc_core_env.py - Twisted event loop
universe/twisty.py
Remote management
- Runtime specifications
universe/runtimes/registration.py - Remote allocator
universe/remotes/allocator_remote.py - Docker remote
universe/remotes/docker_remote.py - Remote interface
universe/remotes/remote.py - Environment container
universe/remotes/compose/container.py
VNC transport
- VNC action and event spaces
universe/spaces/vnc_event.py - VNC session
universe/vncdriver/libvnc_session.py - VNC protocol client
universe/vncdriver/vnc_client.py - VNC server messages
universe/vncdriver/server_messages.py
Reward channel
- Reward session
universe/rewarder/rewarder_session.py - Reward WebSocket client
universe/rewarder/rewarder_client.py - Episode status
universe/rewarder/env_status.py - Reward buffer
universe/rewarder/reward_buffer.py - Reward aggregation
universe/rewarder/merge.py
Other components
- Training agent
- Docker service
- Hosted application
- Reward service
Connections 28
- Training agent → Environment registry: selects environment
- Environment registry → Gym wrappers: registers entry points
universe/__init__.py - Training agent → Gym wrappers: steps environment
- Gym wrappers → VNC environment client: delegates to
universe/wrappers/gym_core.py - Gym wrappers → Game and browser environments: translates actions
universe/wrappers/gym_core.py - Vector environments → Gym wrappers: wraps environments
universe/vectorized/core.py - Multiprocess vectorizer → Vector environments: uses vector core
universe/vectorized/multiprocessing_env.py - Diagnostics → VNC environment client: supports inspection
universe/envs/vnc_env.py - VNC environment client → VNC action and event spaces: uses action spaces
- VNC environment client → Remote allocator: builds remotes
universe/envs/vnc_env.py - VNC environment client → VNC session: sends VNC actions
universe/envs/vnc_env.py - VNC environment client → Reward session: queues rewards
- Runtime specifications → Docker remote: configures runtime
universe/remotes/docker_remote.py - Remote allocator → Remote interface: uses remote interface
universe/remotes/allocator_remote.py - Docker remote → Remote interface: implements interface
universe/remotes/docker_remote.py - Docker remote → Environment container: manages containers
universe/remotes/docker_remote.py - Environment container → Docker service: starts container
- Docker service → Hosted application: hosts application
- Hosted application → VNC protocol client: serves display
- VNC session → VNC protocol client: uses protocol client
universe/vncdriver/libvnc_session.py - VNC protocol client → VNC server messages: parses messages
universe/vncdriver/vnc_client.py - VNC protocol client → VNC action and event spaces: sends input events
- Reward session → Reward WebSocket client: connects clients
universe/rewarder/rewarder_session.py - Reward WebSocket client → Reward buffer: records rewards
universe/rewarder/rewarder_client.py - Reward buffer → Episode status: tracks episode status
universe/rewarder/reward_buffer.py - Reward session → Reward aggregation: aggregates rewards
- Reward service → Reward WebSocket client: sends reward messages
- Reward session → Twisted event loop: uses event loop
universe/rewarder/rewarder_session.py