code: def run_episode(env, agent, render=False):
      total_steps = 0  # 记录每个episode走了多少step
      total_reward = 0
  
      obs = env.reset()  # 重置环境, 重新开一局（即开始新的一个episode）
  
      while True:
          action = agent.sample(obs)  # 根据算法选择一个动作
          next_obs, reward, done, _ = env.step(action)  # 与环境进行一个交互
          # 训练 Q-learning算法
          agent.learn(obs, action, reward, next_obs, done)
  
          obs = next_obs  # 存储上一个观察值
          total_reward += reward
          total_steps += 1  # 计算step数
          if render:
              env.render()  # 渲染新的一帧图形
          if done:
              break
      return total_reward, total_steps
  
imports: import gym
  from gridworld import CliffWalkingWapper, FrozenLakeWapper
  from agent import QLearningAgent
  import time
label_desc: Use image node_id 1 for calling a global function with example usage: run_episode(env, agent, render) and returns: total_reward,  total_steps