Metadata-Version: 2.4
Name: botstadia-train
Version: 0.1.0
Requires-Dist: numpy>=1.26
Requires-Dist: gymnasium>=1.0
Requires-Dist: pytest>=8 ; extra == 'dev'
Requires-Dist: pettingzoo>=1.24 ; extra == 'dev'
Requires-Dist: stable-baselines3>=2.4 ; extra == 'dev'
Requires-Dist: sb3-contrib>=2.4 ; extra == 'dev'
Requires-Dist: torch>=2.11 ; extra == 'dev'
Requires-Dist: onnx>=1.17 ; extra == 'dev'
Requires-Dist: onnxscript>=0.2 ; extra == 'dev'
Requires-Dist: onnxruntime>=1.20 ; extra == 'dev'
Requires-Dist: pettingzoo>=1.24 ; extra == 'pettingzoo'
Requires-Dist: stable-baselines3>=2.4 ; extra == 'sb3'
Requires-Dist: sb3-contrib>=2.4 ; extra == 'sb3'
Requires-Dist: torch>=2.11 ; extra == 'sb3'
Requires-Dist: onnx>=1.17 ; extra == 'sb3'
Requires-Dist: onnxscript>=0.2 ; extra == 'sb3'
Requires-Dist: onnxruntime>=1.20 ; extra == 'sb3'
Provides-Extra: dev
Provides-Extra: pettingzoo
Provides-Extra: sb3
Summary: Train bots for BotStadia: every arena as a Gymnasium or PettingZoo environment, on the same session host as real sessions, with self-play and ONNX export for the policy shell.
License: Proprietary
Requires-Python: >=3.11
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Homepage, https://botstadia.com

# botstadia-train

Train bots for [BotStadia](https://botstadia.com): every arena as a Gymnasium or PettingZoo environment, run on the same session host as real sessions, with self-play and the ONNX export the policy shell runs.

```sh
pip install "botstadia-train[sb3]"          # Stable-Baselines3, PyTorch and the export
pip install "botstadia-train[pettingzoo]"   # multi-agent environments
```

```python
from stable_baselines3 import PPO
from botstadia_train import BotstadiaVectorEnv, export, opponents

env = BotstadiaVectorEnv("dance-off", num_envs=8, opponents=opponents.published("dance-off"))
model = PPO("MultiInputPolicy", env.sb3(), verbose=1)
model.learn(2_000_000)
export.sb3(model, env, "policy.onnx")   # then `botstadia build`, `botstadia check`, `botstadia bench`
```

- **Environments:** `BotstadiaEnv` and `BotstadiaVectorEnv` (Gymnasium, N sessions on N threads, `.sb3()` for Stable-Baselines3); `BotstadiaParallelEnv` and `BotstadiaVectorParallelEnv` (PettingZoo, every seat at once). Arenas download from BotStadia's CDN by name; nothing is per arena.
- **Spaces:** observations are a dict of the arena's declared inputs, by name. Continuous actions are in [-1, 1], mapped onto the declared bounds by the same function the policy shell uses.
- **Rewards:** the arena's training-only shaping reward each turn, plus `terminal_reward` × the outcome (1 for a win, −1 for last) at the end. The finishing order is in `info`. The arena's own end is `terminated`; `truncated` is only your `time_limit_turns`. Your seat is drawn per episode.
- **Opponents:** published baselines (`opponents.published`), any bundle (`opponents.Bundle`), Python policies (`opponents.Policy`), and self-play against frozen snapshots (`selfplay.SelfPlay`).
- **Export:** `export.sb3` (PPO, A2C, SAC, TD3, RecurrentPPO) or `export.torch_module`, with two parity checks: PyTorch against ONNX Runtime, and against the real policy shell.

`BOTSTADIA_CDN_URL` and `BOTSTADIA_CACHE` move the CDN and the cache, shared with the `botstadia` CLI.

