Forest-Fire/gridworld-openenv
๐ Autonomous Navigation RL Environment (OpenEnv Compatible)
A lightweight, API-driven Reinforcement Learning environment that simulates robot navigation in a 2D GridWorld with obstacles, traps, and dynamic challenges.
๐ง Overview
This project implements a GridWorld environment where an agent must navigate from a start position to a goal while avoiding hazards and penalties.
Environment Elements
- ๐ซ Obstacles โ Block movement
- โ ๏ธ Traps โ Penalize the agent
- ๐พ Enemy (Hard Mode) โ Introduces dynamic difficulty
The environment is exposed via a FastAPI interface and is fully Dockerized for easy deployment.
๐ฏ Features
- โ OpenEnv-compliant API
- โ Three difficulty levels: easy, medium, hard
- โ
Reward normalization (
0.0 โ 1.0) - โ Fully Dockerized setup
- โ Lightweight and CPU-friendly
- โ Inference script for evaluation
- โ Stable API with no validation errors
๐ฎ Action Space
๐งฎ Reward System
The reward function is designed to guide efficient navigation:
- โ Step penalty (encourages shorter paths)
- ๐ Distance-based reward shaping
- โ ๏ธ Trap penalty
- ๐พ Enemy penalty (hard mode)
- ๐ Goal reward
๐ Final reward is normalized to `[0, 1]`
๐ API Endpoints
๐น Reset Environment
POST /reset?task=easy
Query Params:
task:easy | medium | hard
๐น Take a Step
POST /step
Request Body:
{
"action": 1
}Response:
{
"state": [x, y],
"reward": 0.85,
"done": false
}๐น Get Current State
GET /state๐งช Inference
Run the evaluation script:
python inference.pyOutput Format
[START]
[STEP] action=...
[STEP] action=...
[END]๐ณ Docker Setup
Build Image
docker build -t env-test .Run Container
docker run -p 7860:7860 env-testThe API will be available at:
http://localhost:7860๐ Project Structure
app/
โโโ api.py # FastAPI routes
โโโ env.py # Core environment logic
โโโ models.py # Data models (request/response)
โโโ tasks.py # Task configurations
โโโ graders.py # Evaluation logic
inference.py # Agent interaction script
Dockerfile # Container configuration
requirements.txt # Dependencies
openenv.yaml # OpenEnv specification
LICENSE๐ Tasks
โ๏ธ State Representation
- Format:
[x, y] - Represents agent position in the grid
- Fully compliant with OpenEnv expectations
โ Submission Ready
- โ Correct state format
- โ Normalized rewards
- โ Stable API responses
- โ No validation errors
๐ This environment is fully evaluator-ready.
๐ License
This project is released under the MIT License.
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
