* Set the state of the cart-pole system randomly.
()
| 64 | * Set the state of the cart-pole system randomly. |
| 65 | */ |
| 66 | setRandomState() { |
| 67 | // The control-theory state variables of the cart-pole system. |
| 68 | // Cart position, meters. |
| 69 | this.x = Math.random() - 0.5; |
| 70 | // Cart velocity. |
| 71 | this.xDot = (Math.random() - 0.5) * 1; |
| 72 | // Pole angle, radians. |
| 73 | this.theta = (Math.random() - 0.5) * 2 * (6 / 360 * 2 * Math.PI); |
| 74 | // Pole angle velocity. |
| 75 | this.thetaDot = (Math.random() - 0.5) * 0.5; |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * Get current state as a tf.Tensor of shape [1, 4]. |
no outgoing calls
no test coverage detected