CoolFace
Apppublic

tukaram12/RL-task-manager

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

Grid-based RL Mini-Game Environment

Project Description

This is a comprehensive, production-ready reinforcement learning environment designed for Hugging Face Spaces. It strictly follows OpenEnv API standards. The game challenges an agent to navigate a 10x10 grid from a starting point (top-left) to a goal point (bottom-right) while avoiding traps and collecting optional rewards.

API Endpoints (FastAPI)

The environment provides the standard RL endpoints via FastAPI:

  • POST /reset Returns: {"observation": <Observation>}
  • POST /step Expects Body: {"direction": "<up|down|left|right>"} Returns: {"observation": <Observation>, "reward": <float>, "done": <bool>}
  • GET /state Returns: <Observation>

Observation and Action Spaces

Observation (Pydantic Model)

  • agent_position: Tuple[int, int]
  • goal_position: Tuple[int, int]
  • grid_size: int
  • steps_taken: int

Action (Pydantic Model)

  • direction: Literal string containing either "up", "down", "left", or "right".

Reward Logic

  • Base turn penalty: -1.0 (encourages taking the shortest path)
  • Reaching the goal: +10.0
  • Hitting a trap: -5.0
  • Collecting a reward cell: +3.0

Graders & Difficulties

The environment specifies three difficulty tasks:

  • Easy: Just reach the goal.
  • Medium: Reach the goal efficiently with fewer steps.
  • Hard: Reach the goal under a strict, unforgiving step-limit.

Instructions to Run Locally

  1. 1.Install dependencies:
bash
   pip install -r requirements.txt
  1. 1.Start the OpenEnv FastAPI Server:
bash
   uvicorn app:app --host 127.0.0.1 --port 7860
  1. 1.Run the Streamlit UI (in a new terminal window):
bash
   streamlit run streamlit_app.py
  1. 1.Evaluate the baseline agent:
bash
   python inference.py

Deploying to Hugging Face Spaces

This project includes a standard Dockerfile setup for Docker runtime SDK on Hugging Face Spaces. Simply push the repository to a space with SDK set to Docker, and the API will be exposed on port 7860 automatically.