Exemplo n.º 1
0
 def step(self, action):
     utils.send_message(self.sock,
                        gym_uds_pb2.Request(type=gym_uds_pb2.Request.STEP))
     utils.send_message(self.sock, gym_uds_pb2.Action(value=action))
     state_pb = utils.recv_message(self.sock, gym_uds_pb2.State)
     observation = np.asarray(state_pb.observation.data).reshape(
         state_pb.observation.shape)
     return observation, state_pb.reward, state_pb.done
Exemplo n.º 2
0
    def Sample(self, empty_request, context):
        action = self.env.action_space.sample()
        
        if (isinstance(action, (np.ndarray, np.generic))):
            act = action.tolist()
        elif (isinstance(action, tuple)):
            act = [x for x in action]
        elif (isinstance(action, int)):
            act = [float(action)]
        elif (isinstance(action, float)):
            act = [action]

        return gym_uds_pb2.Action(data=act)
Exemplo n.º 3
0
 def Sample(self, empty_request, context):
     action = self.env.action_space.sample()
     return gym_uds_pb2.Action(value=action)
Exemplo n.º 4
0
 def step(self, action):
     state_pb = self.stub.Step(gym_uds_pb2.Action(value=action))
     observation = np.asarray(state_pb.observation.data).reshape(
         state_pb.observation.shape)
     return observation, state_pb.reward, state_pb.done
Exemplo n.º 5
0
 def sample(self):
     action = self.env.action_space.sample()
     utils.send_message(self.sock, gym_uds_pb2.Action(value=action))