bitrl & cuberl Documentation
Simulation engine for reinforcement learning agents
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
5#include <boost/noncopyable.hpp>
6
7namespace cuberl {
8namespace rl {
9namespace agents {
10
11
15template<typename EnvType, typename PolicyType>
16class DummyAgent final: private boost::noncopyable{
17
18public:
19
20
21 typedef EnvType env_type;
22 typedef typename env_type::state_type state_type;
23 typedef typename env_type::action_type action_type;
24 typedef PolicyType policy_type;
25
30 explicit DummyAgent(const policy_type& policy );
31
35 template<typename Criteria>
36 void play(EnvType& env, Criteria& criteria);
37
43 action_type on_state(const state_type& state);
44
45protected:
46
51
52};
53
54template<typename EnvType, typename PolicyType>
56 :
57 policy_(policy)
58{}
59
60template<typename EnvType, typename PolicyType>
61template<typename Criteria>
62void
63DummyAgent<EnvType, PolicyType>::play(EnvType& env, Criteria& criteria){
64
65 auto time_step = env.reset();
66
67 while(criteria.continue_iterations()){
68
69 auto action = on_state(time_step.observation());
70 auto time_step = env.step(action);
71
72 if(time_step.done()){
73 time_step = env.reset();
74 }
75 }
76}
77
78template<typename EnvType, typename PolicyType>
81
82 return policy_.on_state(state);
83}
84
85}
86
87}
88
89}
90
91#endif // DUMMY_AGENT_H
Definition dummy_agent.h:16
const policy_type & policy_
policy_
Definition dummy_agent.h:50
EnvType env_type
Definition dummy_agent.h:21
DummyAgent(const policy_type &policy)
DummyAgent.
Definition dummy_agent.h:55
env_type::action_type action_type
Definition dummy_agent.h:23
action_type on_state(const state_type &state)
on_state
Definition dummy_agent.h:80
env_type::state_type state_type
Definition dummy_agent.h:22
PolicyType policy_type
Definition dummy_agent.h:24
void play(EnvType &env, Criteria &criteria)
Definition dummy_agent.h:63
Various utilities used when working with RL problems.
Definition cuberl_types.h:16
Definition play.py:1