CoolFace
Apppublic

ace3848w34u32y/grid-world-navigator

sourceHugging Faceupdated 6mo agoView on Hugging Face
0likes
App README

Grid World Navigator — OpenEnv Mini RL Environment

A Mini Reinforcement Learning environment where an agent navigates a grid world to reach a goal while avoiding walls. Built for the Meta PyTorch OpenEnv Hackathon x Scaler School of Technology — Round 1.

🎯 Tasks

  1. 1.Navigate from a random start position to the goal (bottom-right corner)
  2. 2.Avoid wall collisions (walls are randomly placed)
  3. 3.Minimize steps taken (shortest path is rewarded)

🏆 Graders

GraderDescriptionRange
successBinary: 1.0 if goal reached, 0.0 otherwise0.0 – 1.0
path_efficiencyOptimal distance / actual steps0.0 – 1.0
collision_score1.0 = no collisions, decreases with hits0.0 – 1.0

💰 Reward Logic

EventReward
Each step-0.01 (encourage shortest path)
Hit wall-0.1 (penalize collisions)
Hit edge-0.05 (out of bounds)
Reach goal+1.0 (episode ends)
Max steps exceeded-0.5 (episode ends)

🏗️ Architecture

Follows the OpenEnv 3-component pattern:

grid-world-navigator/
├── models.py              # Pydantic models: GridAction, GridObservation, GridState
├── client.py              # WebSocket client communication
├── server/
│   ├── environment.py     # Core logic: reset(), step(), state(), graders
│   ├── app.py             # FastAPI routing
│   └── Dockerfile         # Containerization
├── openenv.yaml           # Environment manifest
├── pyproject.toml         # Python package config
└── requirements.txt       # Dependencies

🚀 Quick Start

Local Development

bash
cd grid-world-navigator
uv sync && uv run server
# Or with uvicorn directly:
uvicorn server.app:app --host 0.0.0.0 --port 8000 --reload

Test health:

bash
curl http://localhost:8000/health

Docker

bash
docker build -t grid-world-navigator:latest -f server/Dockerfile .
docker run -d -p 8000:8000 grid-world-navigator:latest

Deploy to Hugging Face

bash
openenv push --repo-id username/grid-world-navigator

🎮 Action Space

Action IDDirection
0UP
1DOWN
2LEFT
3RIGHT

📐 Observation Space

The agent receives a GridObservation containing:

  • —grid: 5x5 2D list (0=empty, 1=wall, 2=goal, 3=agent)
  • —agent_pos: [row, col] of the agent
  • —goal_pos: [row, col] of the goal
  • —steps_taken: number of steps so far
  • —message: feedback string

📋 API Methods

MethodReturnsDescription
reset()GridObservationStart new episode with random layout
step(action)GridObservationMove agent, return updated state
state()GridStateFull internal state for debugging

🛠️ Tech Stack

  • —Python 3.11+
  • —OpenEnv — Standardized RL environment framework
  • —Pydantic — Type-safe data models
  • —FastAPI + Uvicorn — Async WebSocket server
  • —Docker — Containerization

📜 License

MIT — Built for the Meta PyTorch OpenEnv Hackathon 2026.