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

Function simulateGameHandler

data-generator/index.js:74–81  ·  view source on GitHub ↗

* Collects one random play of the game. Processes the sample to generate * features and labels representation of the play. Calls a UI method to render * the sample and the processed sample. * @param {bool} wantNewGame : If true, a new game is generated.

(wantNewGame)

Source from the content-addressed store, hash-verified

72 * @param {bool} wantNewGame : If true, a new game is generated.
73 */
74async function simulateGameHandler(wantNewGame) {
75 if (wantNewGame) {
76 SAMPLE_GAME_STATE = game.generateOnePlay();
77 }
78 const featuresAndLabel = gameToFeaturesAndLabel(SAMPLE_GAME_STATE);
79 ui.displaySimulation(SAMPLE_GAME_STATE, featuresAndLabel);
80 ui.displayNumSimulationsSoFar();
81}
82
83/**
84 * This is pulled into a separate function to isolate the async code.

Callers 2

index.jsFile · 0.85

Calls 1

gameToFeaturesAndLabelFunction · 0.85

Tested by

no test coverage detected