async function step() {
  const {reward, done, fruitEaten} = game.step(bestAction);
  invalidateQValuesAndBestAction();
  cumulativeReward += reward;
  if (fruitEaten) {
    cumulativeFruits++;
  }
  gameStatusSpan.textContent =
      `Reward=${cumulativeReward.toFixed(1)}; Fruits=${cumulativeFruits}`;
  if (done) {
    gameStatusSpan.textContent += '. Game Over!';
    cumulativeReward = 0;
    cumulativeFruits = 0;
    if (autoPlayIntervalJob) {
      clearInterval(autoPlayIntervalJob);
      autoPlayStopButton.click();
    }
    autoPlayStopButton.disabled = true;
    stepButton.disabled = true;
  }
  await calcQValuesAndBestAction();
  renderSnakeGame(gameCanvas, game,
      showQValuesCheckbox.checked ? currentQValues : null);
}
Play a game for one step.

- Use the current best action to forward one step in the game.
- Accumulate to the cumulative reward.
- Determine if the game is over and update the UI accordingly.
- If the game has not ended, calculate the current Q-values and best action.
- Render the game in the canvas.