Source code for amaze.simu.controllers.random

import math
from random import Random
from typing import List

from ..robot import Robot, InputType, OutputType
from ..controllers.base import BaseController
from ..types import Action


[docs] class RandomController(BaseController): _savable = False def __init__(self, robot_data: Robot.BuildData, seed=None): super().__init__(robot_data=robot_data) self.seed = seed self.rng = Random(seed) def __call__(self, _) -> Action: if self.output_type is OutputType.DISCRETE: return self.rng.choice(self.discrete_actions) else: return Action.from_polar(self.rng.random() * math.pi, self.rng.random()) def reset(self): self.rng = Random(self.seed)
[docs] @staticmethod def inputs_types() -> List[InputType]: return list(InputType)
[docs] @staticmethod def outputs_types() -> List[OutputType]: return list(OutputType)