Source code for torchrl.controllers.controller

import abc
import gym


[docs]class Controller(metaclass=abc.ABCMeta):
[docs] @abc.abstractmethod def act(self, obs): raise NotImplementedError
[docs] def learn(self) -> dict: '''Placeholder method for the learning algorithm ''' return {}
[docs]class RandomController(Controller): def __init__(self, action_space: gym.Space): self.action_space = action_space
[docs] def act(self, obs): return [self.action_space.sample() for _ in range(len(obs))]