def get_scene(self, state): """ Return scene (list of shapes) representing a given state """ scene = Scene() agent = GeometricPrimitive("QUADS") agent.set_color((0.75, 0.0, 0.5)) size = 0.25 x = state + 0.5 y = 0.5 agent.add_vertex((x - size / 4.0, y - size)) agent.add_vertex((x + size / 4.0, y - size)) agent.add_vertex((x + size / 4.0, y + size)) agent.add_vertex((x - size / 4.0, y + size)) agent.add_vertex((x - size, y - size / 4.0)) agent.add_vertex((x + size, y - size / 4.0)) agent.add_vertex((x + size, y + size / 4.0)) agent.add_vertex((x - size, y + size / 4.0)) scene.add_shape(agent) return scene
def get_scene(self, state): """ Return scene (list of shapes) representing a given state """ x, y = state scene = Scene() agent = circle_shape((x, y), 0.02, n_points=5) agent.type = "POLYGON" agent.set_color((0.75, 0.0, 0.5)) scene.add_shape(agent) return scene
def get_scene(self, state): scene = Scene() p0 = (0.0, 0.0) p1 = (self.LINK_LENGTH_1 * np.sin(state[0]), -self.LINK_LENGTH_1 * np.cos(state[0])) p2 = (p1[0] + self.LINK_LENGTH_2 * np.sin(state[0] + state[1]), p1[1] - self.LINK_LENGTH_2 * np.cos(state[0] + state[1])) link1 = bar_shape(p0, p1, 0.1) link1.set_color((255 / 255, 140 / 255, 0 / 255)) link2 = bar_shape(p1, p2, 0.1) link2.set_color((210 / 255, 105 / 255, 30 / 255)) joint1 = circle_shape(p0, 0.075) joint1.set_color((255 / 255, 215 / 255, 0 / 255)) joint2 = circle_shape(p1, 0.075) joint2.set_color((255 / 255, 215 / 255, 0 / 255)) goal_line = GeometricPrimitive("LINES") goal_line.add_vertex((-5, 1)) goal_line.add_vertex((5, 1)) scene.add_shape(link1) scene.add_shape(link2) scene.add_shape(joint1) scene.add_shape(joint2) scene.add_shape(goal_line) return scene
def get_scene(self, state): scene = Scene() agent = GeometricPrimitive("QUADS") agent.set_color((0.0, 0.0, 0.0)) size = 0.025 x = state[0] y = self._height(x) agent.add_vertex((x - size, y - size)) agent.add_vertex((x + size, y - size)) agent.add_vertex((x + size, y + size)) agent.add_vertex((x - size, y + size)) scene.add_shape(agent) return scene
def get_scene(self, state): """ Return scene (list of shapes) representing a given state """ y, x = self.index2coord[state] x = x + 0.5 # centering y = y + 0.5 # centering scene = Scene() agent = circle_shape((x, y), 0.25, n_points=5) agent.type = "POLYGON" agent.set_color((0.75, 0.0, 0.5)) scene.add_shape(agent) return scene
def get_background(self): bg = Scene() mountain = GeometricPrimitive("TRIANGLE_FAN") flag = GeometricPrimitive("TRIANGLES") mountain.set_color((0.6, 0.3, 0.0)) flag.set_color((0.0, 0.5, 0.0)) # Mountain mountain.add_vertex((-0.3, -1.0)) mountain.add_vertex((0.6, -1.0)) n_points = 50 obs_range = self.observation_space.high[ 0] - self.observation_space.low[0] eps = obs_range / (n_points - 1) for ii in reversed(range(n_points)): x = self.observation_space.low[0] + ii * eps y = self._height(x) mountain.add_vertex((x, y)) mountain.add_vertex((-1.2, -1.0)) # Flag goal_x = self.goal_position goal_y = self._height(goal_x) flag.add_vertex((goal_x, goal_y)) flag.add_vertex((goal_x + 0.025, goal_y + 0.075)) flag.add_vertex((goal_x - 0.025, goal_y + 0.075)) bg.add_shape(mountain) bg.add_shape(flag) return bg
def get_background(self): """ Returne a scene (list of shapes) representing the background """ bg = Scene() # walls for wall in self.walls: y, x = wall shape = GeometricPrimitive("POLYGON") shape.set_color((0.25, 0.25, 0.25)) shape.add_vertex((x, y)) shape.add_vertex((x + 1, y)) shape.add_vertex((x + 1, y + 1)) shape.add_vertex((x, y + 1)) bg.add_shape(shape) # rewards for (y, x) in self.reward_at: flag = GeometricPrimitive("POLYGON") rwd = self.reward_at[(y, x)] if rwd > 0: flag.set_color((0.0, 0.5, 0.0)) if rwd < 0: flag.set_color((0.5, 0.0, 0.0)) x += 0.5 y += 0.25 flag.add_vertex((x, y)) flag.add_vertex((x + 0.25, y + 0.5)) flag.add_vertex((x - 0.25, y + 0.5)) bg.add_shape(flag) return bg
def get_background(self): """ Returne a scene (list of shapes) representing the background """ bg = Scene() colors = [(0.8, 0.8, 0.8), (0.9, 0.9, 0.9)] for ii in range(self.L): shape = GeometricPrimitive("QUADS") shape.add_vertex((ii, 0)) shape.add_vertex((ii + 1, 0)) shape.add_vertex((ii + 1, 1)) shape.add_vertex((ii, 1)) shape.set_color(colors[ii % 2]) bg.add_shape(shape) flag = GeometricPrimitive("TRIANGLES") flag.set_color((0.0, 0.5, 0.0)) x = self.L - 0.5 y = 0.25 flag.add_vertex((x, y)) flag.add_vertex((x + 0.25, y + 0.5)) flag.add_vertex((x - 0.25, y + 0.5)) bg.add_shape(flag) return bg
def get_background(self): """ Returne a scene (list of shapes) representing the background """ bg = Scene() # wall eps = self.wall_eps shape = GeometricPrimitive("POLYGON") shape.set_color((0.25, 0.25, 0.25)) shape.add_vertex((1 - eps, 0)) shape.add_vertex((1 - eps, 1)) shape.add_vertex((1 + eps, 1)) shape.add_vertex((1 + eps, 0)) bg.add_shape(shape) # rewards for (x, y) in [ self.base_reward_pos, self.base_reward_pos + np.array([1.0, 0.0]), ]: reward = circle_shape((x, y), 0.1, n_points=50) reward.type = "POLYGON" reward.set_color((0.0, 0.5, 0.0)) bg.add_shape(reward) return bg
def __init__(self): # parameters self.window_width = 800 self.window_height = 800 # multiples of 16 are preferred self.background_color = (150, 190, 255) self.refresh_interval = 50 self.window_name = "rlberry render" self.clipping_area = (-1.0, 1.0, -1.0, 1.0) # time counter self.time_count = 0 # background scene self.background = Scene() # data to be rendered (list of scenes) self.data = []
def get_scene(self, state): scene = Scene() p0 = (0.0, 0.0) p1 = (self.length * np.sin(state[0]), -self.length * np.cos(state[0])) link = bar_shape(p0, p1, 0.1) link.set_color((255 / 255, 105 / 255, 30 / 255)) joint = circle_shape(p0, 0.075) joint.set_color((255 / 255, 215 / 255, 0 / 255)) scene.add_shape(link) scene.add_shape(joint) return scene
def get_background(self): bg = Scene() # ball shape contour = self._get_ball_shape(np.zeros(2), 1.0) contour.set_color((0.0, 0.0, 0.5)) bg.add_shape(contour) # reward position for ii, ampl in enumerate(self.reward_amplitudes): contour = self._get_ball_shape(self.reward_centers[ii], self.reward_smoothness[ii]) ampl = 1.0 - ampl # dark violet = more reward contour.set_color((0.5, 0.0, 0.5 * (1.0 + ampl))) bg.add_shape(contour) return bg
def get_background(self): bg = Scene() return bg