How to use the openai.BoolConv function in openai

To help you get started, we’ve selected a few openai examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vladfi1 / phillip / openai.py View on Github external
buttons = ['A', 'B', 'Y', 'L', 'Z']

button_space = spaces.Discrete(len(buttons) + 1)
main_stick_space = spaces.Box(0, 1, [2]) # X and Y axes
c_stick_space = spaces.Discrete(5) # neutral up down left right

controller_space = spaces.Tuple((button_space, main_stick_space, c_stick_space))

class BoolConv:
  def __init__(self):
    self.space = spaces.Discrete(2)
  def __call__(self, cbool):
    #assert type(cbool) is bool
    return int(cbool)

boolConv = BoolConv()

def clip(x, min_x, max_x):
  return min(max(x, min_x), max_x)

class RealConv:
  def __init__(self, low, high):
    self.space = spaces.Box(low, high, [1])
  
  def __call__(self, x):
    #assert self.space.low <= x and x <= self.space.high
    x = clip(x, self.space.low, self.space.high)
    return np.array([x])

class DiscreteConv:
  def __init__(self, size, name = None):
    self.space = spaces.Discrete(size)