struct TabularAgent {
&FloatTensor q;
unsigned long states;
unsigned long actions;
float alpha;
float gamma;
float epsilon;
struct Rng rng;
}Fields
[states, actions]
step size
discount
exploration (change it to decay)
Methods
epsilon-greedy
§
float q_learning_update(
unsigned long s,
unsigned long act,
float r,
unsigned long s2,
int terminal,
)source · definitionEach returns the TD error. 'terminal' drops the bootstrap term. Q-learning (off-policy): target r + gamma max_a' Q(s', a').
§
float sarsa_update(
unsigned long s,
unsigned long act,
float r,
unsigned long s2,
unsigned long a2,
int terminal,
)source · definitionSARSA (on-policy): target r + gamma Q(s', a') for the a' actually taken next.
§
float expected_sarsa_update(
unsigned long s,
unsigned long act,
float r,
unsigned long s2,
int terminal,
)source · definitionExpected SARSA: target r + gamma E_pi[Q(s', .)] under the epsilon-greedy policy.
= drop()
§
static struct TabularAgent new(
unsigned long states,
unsigned long actions,
float alpha,
float gamma,
float epsilon,
unsigned long seed,
)source · definition