bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
dummy_agent.h
Go to the documentation of this file.
1#ifndef DUMMY_AGENT_H
2#define DUMMY_AGENT_H
3
4#include <boost/noncopyable.hpp>
5
6namespace bitrl
7{
8namespace rl
9{
10namespace agents
11{
12
16template <typename EnvType, typename PolicyType> class DummyAgent final : private boost::noncopyable
17{
18
19 public:
20 typedef EnvType env_type;
21 typedef typename env_type::state_type state_type;
22 typedef typename env_type::action_type action_type;
23 typedef PolicyType policy_type;
24
29 explicit DummyAgent(const policy_type &policy);
30
34 template <typename Criteria> void play(EnvType &env, Criteria &criteria);
35
41 action_type on_state(const state_type &state);
42
43 protected:
48};
49
50template <typename EnvType, typename PolicyType>
54
55template <typename EnvType, typename PolicyType>
56template <typename Criteria>
57void DummyAgent<EnvType, PolicyType>::play(EnvType &env, Criteria &criteria)
58{
59
60 auto time_step = env.reset();
61
62 while (criteria.continue_iterations())
63 {
64
65 auto action = on_state(time_step.observation());
66 time_step = env.step(action);
67
68 if (time_step.done())
69 {
70 time_step = env.reset();
71 }
72 }
73}
74
75template <typename EnvType, typename PolicyType>
78{
79
80 return policy_.on_state(state);
81}
82
83} // namespace agents
84
85} // namespace rl
86
87} // namespace bitrl
88
89#endif // DUMMY_AGENT_H
void play(EnvType &env, Criteria &criteria)
Definition dummy_agent.h:57
PolicyType policy_type
Definition dummy_agent.h:23
env_type::action_type action_type
Definition dummy_agent.h:22
DummyAgent(const policy_type &policy)
DummyAgent.
Definition dummy_agent.h:51
const policy_type & policy_
policy_
Definition dummy_agent.h:47
action_type on_state(const state_type &state)
on_state
Definition dummy_agent.h:77
env_type::state_type state_type
Definition dummy_agent.h:21
EnvType env_type
Definition dummy_agent.h:20
Definition dummy_agent.h:11
Definition dummy_agent.h:9
Various utilities used when working with RL problems.
Definition bitrl_log.h:25
Definition play.py:1