コード例 #1
0
ファイル: conftest.py プロジェクト: svsamipillai/bonsai-sdk
    def episode_start(self, parameters):
        parameters['pixels'] = Luminance(self.width, self.height,
                                         [0, 1, 2, 3, 4, 5])

        print('episode_start: ', parameters['pixels'])
        initial = {
            "pixels": Luminance(self.width, self.height, self.STATE_PIXELS)
        }
        return initial
コード例 #2
0
 def render(self):
     for i in range(3):
         for j in range(3):
             self.image[i * 3:i * 3 + 3,
                        j * 3:j * 3 + 3] = letters[self.board[i * 3 + j]]
     image = Luminance(9, 9, self.image.ravel().tolist())
     return image
コード例 #3
0
    def gym_to_state(self, observation):
        """
        Calculates the luminance of the values for the image and
        performs nice preprocessing.
        """

        R = observation[:, :, 0]
        G = observation[:, :, 1]
        B = observation[:, :, 2]

        # Calculates weighted apparent brightness values
        # according to https://en.wikipedia.org/wiki/Relative_luminance
        observation = 0.2126 * R + 0.7152 * G + 0.0722 * B

        # Normalize the observations.
        observation /= 255.0

        # should be replaced with tranformed
        observation = observation[::self.downsample, ::self.downsample]

        observation = observation.ravel().tolist()

        return {
            'observation': Luminance(
                int(self.env_width / self.downsample),
                int(self.env_height / self.downsample),
                observation)
        }
コード例 #4
0
ファイル: conftest.py プロジェクト: svsamipillai/bonsai-sdk
    def simulate(self, action):
        print('simulate: ', action)
        terminal = True

        state = {
            "pixels": Luminance(self.width, self.height,
                                [0, -1, 1000, 1, 2, 3])
        }

        return (state, 1.0, terminal)