Calculate the current Q-values and the best action.
()
| 91 | |
| 92 | /** Calculate the current Q-values and the best action. */ |
| 93 | async function calcQValuesAndBestAction() { |
| 94 | if (currentQValues != null) { |
| 95 | return; |
| 96 | } |
| 97 | tf.tidy(() => { |
| 98 | const stateTensor = getStateTensor(game.getState(), game.height, game.width); |
| 99 | const predictOut = qNet.predict(stateTensor); |
| 100 | currentQValues = predictOut.dataSync(); |
| 101 | bestAction = ALL_ACTIONS[predictOut.argMax(-1).dataSync()[0]]; |
| 102 | }); |
| 103 | } |
| 104 | |
| 105 | function invalidateQValuesAndBestAction() { |
| 106 | currentQValues = null; |
no test coverage detected