-
Notifications
You must be signed in to change notification settings - Fork 4
Gymnasium
Francois edited this page Feb 7, 2026
·
1 revision
Presentation : Gymnasium is an open-source Python library that provides a standard API for reinforcement learning (RL) environments. It is the maintained fork of OpenAI Gym and serves as the bridge between AI agent (trained with PPO from Stable Baselines3) and the game logic.
Every Gymnasium environment relies on these fundamental building blocks:
- Observation Space: Defines the structure of the data the agent "sees" (e.g., ball position, player position).
- Action Space: Defines the allowed moves (e.g., 0: Stay, 1: Up, 2: Down).
-
reset(): Resets the environment to an initial state and returns the first observation. -
step(action): Processes the action, updates the game state, and returns:- Observation: The new state of the game.
- Reward: A numerical value (e.g., +1 for scoring, -1 for conceding).
- Terminated: Boolean indicating if the game ended (e.g., someone reached 11 points).
- Truncated: Boolean indicating if the episode was cut short (e.g., time limit).
- Info: A dictionary for auxiliary debugging data.
| โ Do | โ Don't |
|---|---|
Use float32: Ensure your Box spaces use np.float32 for compatibility with PyTorch/Stable Baselines3. |
Heavy loops: Avoid complex calculations inside step(); keep the physics engine efficient. |
Check Compliance: Use gymnasium.utils.env_checker.check_env to verify your environment follows the API. |
Global variables: Don't store game state in global variables; keep everything inside the class instance. |
| Reward Shaping: Provide small intermediate rewards (e.g., for hitting the ball) to help the agent learn faster. | Ignore Terminated: Don't forget to stop the episode; otherwise, the agent will learn "infinite" loops. |
| Type | Resource | Notes |
|---|---|---|
| ๐ | Official Docs | Complete API reference |
| ๐ป | Gymnasium Github | Source code and issues |
| ๐ | Environment Creation Guide | Step-by-step tutorial |
Legend: ๐ Doc, ๐ Book, ๐ฅ Video, ๐ป GitHub, ๐ฆ Package, ๐ก Blog
- Gateway Service - API Gateway & JWT validation
- Auth Service - Authentication & 2FA/TOTP
- AI Service - AI opponent
- API Documentation - OpenAPI/Swagger
- DB Schema - Databases
- Fastify - Web framework
- Prisma - ORM
- WebSockets - Real-time communication
- Restful API - API standards
- React - UI library
- CSS - Styling
- Tailwind - CSS framework
- Accessibility - WCAG compliance
- TypeScript - Language
- Zod - Schema validation
- Nginx - Reverse proxy
- Logging and Error management - Observability
- OAuth 2.0 - Authentication flows
- Two-factor authentication - 2FA/TOTP
- Avalanche - Blockchain network
- Hardhat - Development framework
- Solidity - Smart contracts language
- Open Zeppelin - Security standards
- ESLint - Linting
- Vitest - Testing
- GitHub Actions - CI/CD
- Husky, Commit lints and git hooks - Git hooks
- ELK - Logging stack
๐ Page model