std1.0.0-beta-7 SafeC docs

std :: ml::rl

Struct std::GridWorld

#include <std/ml/rl.h> source

struct GridWorld {
    &FloatTensor cells;
    unsigned long width;
    unsigned long height;
    unsigned long start;
    unsigned long state;
    float stepReward;
    float pitReward;
    float goalReward;
    int pitTerminal;
    float slip;
    unsigned long steps;
    unsigned long maxSteps;
    struct Rng rng;
}

Fields

[height * width] GRID_* tags, row 0 at the top

§unsigned long widthsource
§unsigned long heightsource
§unsigned long startsource

state index y * width + x

§unsigned long statesource
§float stepRewardsource

every move (default -1)

§float pitRewardsource

default -100

§float goalRewardsource

default 0

§int pitTerminalsource

default 0 (cliff walk: back to start)

§float slipsource

probability the move goes a random way (0)

§unsigned long stepssource
§unsigned long maxStepssource

truncation (default 1000)

§struct Rng rngsource

Methods

§void set(unsigned long x, unsigned long y, int cell)source · definition
§void set_start(unsigned long x, unsigned long y)source · definition
§unsigned long states() constsource · definition
§unsigned long reset()source · definition

-> start state

§struct EnvStep step(unsigned long action, &unsigned long next)source · definition
§void one_hot(unsigned long state, &FloatTensor obs) constsource · definition

One-hot observation of a state (for neural agents), obs has states() values.

§void drop()source · definition
§void free() consumesource · definition

= drop()

§static struct GridWorld new(unsigned long width, unsigned long height, unsigned long seed)source · definition

An empty w x h grid, start top-left, goal bottom-right.

§static struct GridWorld cliff(unsigned long seed)source · definition

The 12 x 4 cliff walk: start bottom-left, goal bottom-right, the bottom row between them a cliff (-100, back to start).