Environment

Constructors

this
this(string address, string id)
Undocumented in source.

Members

Functions

_get
auto _get(string loc)
Undocumented in source. Be warned that the author may not have intended to support it.
_post
auto _post(T req)
Undocumented in source. Be warned that the author may not have intended to support it.
_post
auto _post(string loc, T req)
Undocumented in source. Be warned that the author may not have intended to support it.
record
auto record(string dir, bool force, bool resume)
Undocumented in source. Be warned that the author may not have intended to support it.
reset
auto reset()
Undocumented in source. Be warned that the author may not have intended to support it.
step
auto step(A action, bool render)

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

stop
auto stop()
Undocumented in source. Be warned that the author may not have intended to support it.
upload
auto upload(string dir, string apiKey, string algorithmId)
Undocumented in source. Be warned that the author may not have intended to support it.

Variables

actionInfo
JSONValue actionInfo;
Undocumented in source.
address
string address;
id
string id;
Undocumented in source.
instanceId
string instanceId;
Undocumented in source.
observationInfo
JSONValue observationInfo;
Undocumented in source.

Examples

simple integration test

{
    auto env = Environment("127.0.0.1:5000", "CartPole-v0");
    assert(Discrete.from(env.actionInfo) == 2);
    auto o = Box.from(env.observationInfo);
    assert(o.shape == [4]);
    assert(o.low.length == 4);
    env.record("/tmp/d-gym");
    scope(exit) env.stop();

    auto state = env.reset;
    double reward = 0;
    while (!state.done) {
        state = env.step(Discrete(0));
        reward += state.reward;
    }
    assert(reward > 0);
}
// {
//     auto env = Environment("127.0.0.1:5000", "MsPacman-v0");
//     assert(Discrete.from(env.actionInfo) == 9);
//     auto o = Box.from(env.observationInfo);
//     assert(o.shape == [210, 160, 3]);
//     assert(o.high.length == 210 * 160 * 3);
//     auto a = Discrete.from(env.actionInfo);
//     assert(a == 9);
// }

Meta