Environment

struct Environment {
string address;
string id;
string instanceId;
JSONValue actionInfo;
JSONValue observationInfo;
}

Members

Functions

step
auto step(A action, bool render = false)

step by json action e.g., 0, [1.0, 2.0, ...], etc

Examples

simple integration test

1 {
2     auto env = Environment("127.0.0.1:5000", "CartPole-v0");
3     assert(Discrete.from(env.actionInfo) == 2);
4     auto o = Box.from(env.observationInfo);
5     assert(o.shape == [4]);
6     assert(o.low.length == 4);
7     env.record("/tmp/d-gym");
8     scope(exit) env.stop();
9 
10     auto state = env.reset;
11     double reward = 0;
12     while (!state.done) {
13         state = env.step(Discrete(0));
14         reward += state.reward;
15     }
16     assert(reward > 0);
17 }
18 // {
19 //     auto env = Environment("127.0.0.1:5000", "MsPacman-v0");
20 //     assert(Discrete.from(env.actionInfo) == 9);
21 //     auto o = Box.from(env.observationInfo);
22 //     assert(o.shape == [210, 160, 3]);
23 //     assert(o.high.length == 210 * 160 * 3);
24 //     auto a = Discrete.from(env.actionInfo);
25 //     assert(a == 9);
26 // }

Meta