Spaces:
Runtime error
Runtime error
File size: 809 Bytes
8dc7642 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | from __future__ import annotations
from openenv.core.client_types import StepResult
from openenv.core.env_client import EnvClient
from freeciv_env.models import FreecivAction, FreecivObservation, FreecivState
class FreecivEnv(EnvClient[FreecivAction, FreecivObservation, FreecivState]):
def _step_payload(self, action: FreecivAction) -> dict:
return action.model_dump(exclude_none=True)
def _parse_result(self, payload: dict) -> StepResult[FreecivObservation]:
observation = FreecivObservation(**payload["observation"])
return StepResult(
observation=observation,
reward=payload.get("reward"),
done=payload.get("done", False),
)
def _parse_state(self, payload: dict) -> FreecivState:
return FreecivState(**payload)
|