File size: 1,103 Bytes
6c50d1f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from abc import ABC, abstractmethod
from typing import Any


class BaseAgent(ABC):
    @abstractmethod
    def initialize_q_table(self) -> None:
        """Populate the agent's Q-table before use."""

    @abstractmethod
    def get_action(self, *args: Any, **kwargs: Any) -> Any:
        """Return the next action given the current state information."""

    @abstractmethod
    def get_best_action(self, *args: Any, **kwargs: Any) -> Any:
        """Return the highest-value action for the provided state."""

    @abstractmethod
    def get_random_action(self, *args: Any, **kwargs: Any) -> Any:
        """Return a random action for exploration."""

    @abstractmethod
    def get_Q_next(self, *args: Any, **kwargs: Any) -> Any:
        """Return the next-step Q-value(s) used in TD updates."""

    @abstractmethod
    def get_Q_curr(self, *args: Any, **kwargs: Any) -> Any:
        """Return the current Q-value(s) for the provided state/action."""

    @abstractmethod
    def update_Q_item(self, *args: Any, **kwargs: Any) -> None:
        """Apply a TD-error update to part of the Q-table."""