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_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 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.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_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