Spaces:
Running
Running
Download models.py from openenv/grid_world_env: direct link, hf CLI and curl.
- Browser
- Download file 1.24 kB
-
https://huggingface.co/spaces/openenv/grid_world_env/resolve/main/models.py
- Command line
-
hf download hf://spaces/openenv/grid_world_env/models.py
-
curl -L -o models.py https://huggingface.co/spaces/openenv/grid_world_env/resolve/main/models.py
1.24 kB
| # Copyright (c) Meta Platforms, Inc. and affiliates. | |
| # All rights reserved. | |
| # | |
| # This source code is licensed under the BSD-style license found in the | |
| # LICENSE file in the root directory of this source tree. | |
| from __future__ import annotations | |
| from dataclasses import dataclass | |
| from enum import Enum | |
| from typing import Optional | |
| try: | |
| from openenv.core.env_server.types import Action, Observation | |
| from pydantic import Field | |
| except ImportError: | |
| from core.env_server.types import Action, Observation | |
| from pydantic import Field | |
| # --- Action Models --- | |
| class MoveAction(str, Enum): | |
| UP = "UP" | |
| DOWN = "DOWN" | |
| LEFT = "LEFT" | |
| RIGHT = "RIGHT" | |
| class GridWorldAction(Action): | |
| action: MoveAction = Field(..., description="The direction to move the agent.") | |
| # --- Observation Model --- | |
| class GridWorldObservation(Observation): | |
| x: int = Field(..., description="Current X position") | |
| y: int = Field(..., description="Current Y position") | |
| message: str = Field("", description="Status message") | |
| # Reward must be a float, default to 0.0 (not None) | |
| reward: float = Field(0.0, description="Reward received from the last action") | |
| done: bool = Field(False, description="Whether the episode has ended") | |