MCPcopy Index your code
hub / github.com/tensorflow/tfjs-examples / setRandomState

Method setRandomState

cart-pole/cart_pole.js:66–76  ·  view source on GitHub ↗

* Set the state of the cart-pole system randomly.

()

Source from the content-addressed store, hash-verified

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

Callers 3

constructorMethod · 0.95
setUpUIFunction · 0.95
trainMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected