def animatePolicy(self):
        if robotType != 'pendulum':
            raise 'Only pendulum can animatePolicy'

        totWidth = self.canvas.winfo_reqwidth()
        totHeight = self.canvas.winfo_reqheight()

        length = 0.48 * min(totWidth, totHeight)
        x, y = totWidth - length - 30, length + 10

        angleMin, angleMax = self.robot.getMinAndMaxAngle()
        velMin, velMax = self.robot.getMinAndMaxAngleVelocity()

        if not 'animatePolicyBox' in dir(self):
            self.canvas.create_line(x, y, x + length, y)
            self.canvas.create_line(x + length, y, x + length, y - length)
            self.canvas.create_line(x + length, y - length, x, y - length)
            self.canvas.create_line(x, y - length, x, y)
            self.animatePolicyBox = 1
            self.canvas.create_text(x + length / 2, y + 10, text='angle')
            self.canvas.create_text(x - 30, y - length / 2, text='velocity')
            self.canvas.create_text(
                x - 60,
                y - length / 4,
                text='Blue = kickLeft')
            self.canvas.create_text(
                x - 60,
                y - length / 4 + 20,
                text='Red = kickRight')
            self.canvas.create_text(
                x - 60,
                y - length / 4 + 40,
                text='White = doNothing')

        angleDelta = (angleMax - angleMin) / 100
        velDelta = (velMax - velMin) / 100
        for i in range(100):
            angle = angleMin + i * angleDelta

            for j in range(100):
                vel = velMin + j * velDelta
                state = self.robotEnvironment.getState(angle, vel)
                max, argMax = None, None
                if not self.learner.seenState(state):
                    argMax = 'unseen'
                else:
                    for action in ('kickLeft', 'kickRight', 'doNothing'):
                        qVal = self.learner.getQValue(state, action)
                        if max is None or qVal > max:
                            max, argMax = qVal, action
                if argMax != 'unseen':
                    if argMax == 'kickLeft':
                        color = 'blue'
                    elif argMax == 'kickRight':
                        color = 'red'
                    elif argMax == 'doNothing':
                        color = 'white'
                    dx = length / 100.0
                    dy = length / 100.0
                    x0, y0 = x + i * dx, y - j * dy
                    self.canvas.create_rectangle(
                        x0,
                        y0,
                        x0 +
                        dx,
                        y0 +
                        dy,
                        fill=color)
dataset/ETHPy150Open rlpy/rlpy/rlpy/Domains/PacmanPackage/graphicsCrawlerDisplay.py/Application.animatePolicy/original