r""" Run one episode of n_steps. Args: agent_rref (RRef): an RRef referencing the agent object. n_steps (int): number of steps in this episode
(self, agent_rref, n_steps)
| 88 | self.env.reset(seed=args.seed) |
| 89 | |
| 90 | def run_episode(self, agent_rref, n_steps): |
| 91 | r""" |
| 92 | Run one episode of n_steps. |
| 93 | |
| 94 | Args: |
| 95 | agent_rref (RRef): an RRef referencing the agent object. |
| 96 | n_steps (int): number of steps in this episode |
| 97 | """ |
| 98 | state, ep_reward = self.env.reset()[0], 0 |
| 99 | for step in range(n_steps): |
| 100 | # send the state to the agent to get an action |
| 101 | action = _remote_method(Agent.select_action, agent_rref, self.id, state) |
| 102 | |
| 103 | # apply the action to the environment, and get the reward |
| 104 | state, reward, terminated, truncated, _ = self.env.step(action) |
| 105 | |
| 106 | # report the reward to the agent for training purpose |
| 107 | _remote_method(Agent.report_reward, agent_rref, self.id, reward) |
| 108 | |
| 109 | if terminated or truncated: |
| 110 | break |
| 111 | |
| 112 | class Agent: |
| 113 | def __init__(self, world_size): |
nothing calls this directly
no test coverage detected