File size: 1,035 Bytes
ce614ef
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
"""
base_task.py — Abstract base class for all USAR tasks.
"""

from __future__ import annotations

from abc import ABC, abstractmethod
from typing import Tuple

from ..models import (
    GradeResult, ResetResult, StepResult, TaskInfo, USARAction,
)


class BaseUSARTask(ABC):
    """All USAR tasks inherit from this."""

    @property
    @abstractmethod
    def name(self) -> str: ...

    @property
    @abstractmethod
    def difficulty(self) -> str: ...

    @property
    @abstractmethod
    def threshold(self) -> float: ...

    @property
    @abstractmethod
    def max_steps(self) -> int: ...

    @abstractmethod
    def reset(self, seed: int) -> ResetResult: ...

    @abstractmethod
    def step(self, action: USARAction) -> StepResult: ...

    @abstractmethod
    def grade(self) -> GradeResult: ...

    @abstractmethod
    def get_info(self) -> TaskInfo: ...

    @property
    def done(self) -> bool:
        return self._done

    def _set_done(self, val: bool):
        self._done = val

    _done: bool = False