Metadata-Version: 2.5
Name: computergym
Version: 1.0.0
Summary: ComputerGym is a Gymnasium-compatible framework for reinforcement learning in desktop applications
License-Expression: Apache-2.0
License-File: LICENSE
Requires-Python: >=3.11
Requires-Dist: gymnasium<2,>=1.3
Requires-Dist: mss<11,>=7.0
Requires-Dist: naptime>=1.0
Requires-Dist: numpy<3,>=2.0
Requires-Dist: psutil<8,>=7.0
Requires-Dist: pynput<2,>=1.8
Requires-Dist: pywin32>=311; sys_platform == 'win32'
Description-Content-Type: text/markdown

# ComputerGym

ComputerGym is a Gymnasium-compatible framework for reinforcement learning in
desktop applications. It captures timestamped screen observations and sends
keyboard, mouse, or gamepad input through configurable controllers.

## Installation

Requires Python 3.11 or later. In a uv-managed project, run:

```bash
uv add computergym
```

## Usage

Define actions and their input bindings, create an environment, and call
`reset()` to obtain an initial observation. Use `step()` to execute action sets
and receive observations, rewards, and episode outcomes. Always call `close()`
when finished.

The following example samples keyboard actions at random. It captures the
desktop and sends W or Space to the focused application. Focus the application
you want to control during the three-second delay. Your operating system must
permit screen capture and input injection.

```python
import naptime

from computergym.action import ActionSpace, InputType, PressInput
from computergym.control import Key
from computergym.environment import ComputerEnv

actions = ActionSpace(
    {
        PressInput({InputType.KEYBOARD: {Key.W}}, name="move_forward"),
        PressInput({InputType.KEYBOARD: {Key.SPACE}}, name="jump"),
    }
)

env = ComputerEnv(actions=actions, step_sleep_s=0.1)
try:
    naptime.sleep(3)
    observation, info = env.reset()

    for _ in range(100):
        result = env.step(actions.sample())
        observation = result.observation
        if result.terminated or result.truncated:
            break
finally:
    env.close()
```

Save the example as `example.py` and run it with `uv run python example.py`.
Replace random sampling with your policy. Use observation hooks to define
task-specific rewards and episode outcomes.

## License

ComputerGym is licensed under the Apache License, Version 2.0 (Apache-2.0).
