MCPcopy Create free account
hub / github.com/tensorflow/tfjs-examples / normalizeQValuesForDisplay

Function normalizeQValuesForDisplay

snake-dqn/snake_graphics.js:141–153  ·  view source on GitHub ↗
(qW, qN, qE, qS)

Source from the content-addressed store, hash-verified

139}
140
141function normalizeQValuesForDisplay(qW, qN, qE, qS) {
142 const scores = [qW, qN, qE, qS].filter(x => x != null);
143 const min = Math.min(...scores);
144 const max = Math.max(...scores);
145
146 const normalize = q => (q - min) / (max - min);
147 return {
148 qWNormalized: qW == null ? qW : normalize(qW),
149 qNNormalized: qN == null ? qN : normalize(qN),
150 qENormalized: qE == null ? qE : normalize(qE),
151 qSNormalized: qS == null ? qE : normalize(qS)
152 };
153}
154
155function drawQValueOverlay(context, q, qNormalized, x, y, w, h) {
156 if (q == null) {

Callers 1

renderSnakeGameFunction · 0.85

Calls 1

normalizeFunction · 0.70

Tested by

no test coverage detected