code: def recording_test(
      buttons,
      variables,
      actions,
      recording_file="test_recording.lmp",
      sleep_time=0,
      mode=vzd.Mode.PLAYER,
      verbose=0,
      verbose_sleep_time=0.1,
      title="Unnamed test",
  ):
      print(f"Test: {title}")
  
      game = setup_test(buttons, variables, visible=bool(verbose))
  
      # Append all zeros action
      actions.append([0.0] * game.get_available_buttons_size())
  
      history_of_actions = []
      history_of_variables = []
      history_of_rewards = []
  
      game.init()
      game.new_episode(recording_file)
      for i, action in enumerate(actions):
          print("  Playing:", i, "/", len(actions), end="\r")
  
          normalize_action(action)
          history_of_actions.append(action)
          assert type(action) == list
  
          state = game.get_state()
          variables = normalize_variables(state.game_variables)
          history_of_variables.append(variables)
          assert type(variables) == list
  
          reward = game.make_action(action)
          history_of_rewards.append(reward)
          last_action = game.get_last_action()
          normalize_action(last_action)
          assert type(last_action) == list
  
          if verbose > 1:
              print(
                  "  State: {}, tic: {}, reward: {}, action: {}, last action: {}, variables: {}".format(
                      state.number,
                      state.tic,
                      reward,
                      action,
                      last_action,
                      variables,
                  )
              )
              sleep(verbose_sleep_time)
  
          # Asserts
          assert action == last_action
  
      game.close()
  
      state_number = 0
      error_count = 0
  
      game.set_mode(mode)
      game.init()
      game.replay_episode(recording_file)
      while not game.is_episode_finished() and state_number < len(
          history_of_variables
      ):
          print(
              "  Replaying:",
              state_number,
              "/",
              len(history_of_variables),
              end="\r",
          )
  
          state = game.get_state()
          variables = normalize_variables(state.game_variables)
          assert type(variables) == list
  
          game.advance_action()
          last_action = game.get_last_action()
          reward = game.get_last_reward()
          normalize_action(last_action)
          assert type(last_action) == list
  
          sleep(sleep_time)
  
          if verbose > 1:
              print(
                  "  State: {}, tic: {}, reward: {}, recorded action: {}, last action: {}, recorded variables: {} variables: {}".format(
                      state.number,
                      state.tic,
                      reward,
                      history_of_actions[state_number],
                      last_action,
                      history_of_variables[state_number],
                      variables,
                  )
              )
              sleep(verbose_sleep_time)
  
          # Asserts
          error = False
          try:
              assert history_of_rewards[state_number] == reward
          except AssertionError:
              error = True
              if verbose > 0:
                  print("  Test failed:")
                  print(
                      "    State: {}, tic: {}, recorded reward: {} != reward: {}".format(
                          state.number,
                          state.tic,
                          history_of_rewards[state_number],
                          reward,
                      )
                  )
  
          try:
              assert history_of_variables[state_number] == variables
          except AssertionError:
              error = True
              if verbose > 0:
                  print("  Test failed:")
                  print(
                      "    State: {}, tic: {}, recorded variables: {} != variables: {}".format(
                          state.number,
                          state.tic,
                          history_of_variables[state_number],
                          variables,
                      )
                  )
  
          try:
              assert history_of_actions[state_number] == last_action
          except AssertionError:
              error = True
              if verbose > 0:
                  print("  Test failed:")
                  print(
                      "    State: {}, tic: {}, recorded action: {} != last action: {}".format(
                          state.number,
                          state.tic,
                          history_of_actions[state_number],
                          last_action,
                      )
                  )
  
          if error:
              error_count += 1
          state_number += 1
  
      game.close()
      os.remove(recording_file)
  
      print("  Total errors:", error_count, "/", state_number)
  
file_path: ViZDoom/tests/manual_test_recording.py
imports: import os
  from random import random
  from time import sleep
  import vizdoom
label_desc: Use image node_id 5 for calling a global function with example usage: recording_test(buttons, variables, actions, recording_file, sleep_time, mode, verbose, verbose_sleep_time, title) without return types