-
Notifications
You must be signed in to change notification settings - Fork 0
Reinforcement Learning
eantcal edited this page Jul 7, 2026
·
3 revisions
Reinforcement learning models interaction as a loop between an agent and an environment.

At each step:
- the agent observes a state;
- it chooses an action;
- the environment returns a new state and a reward;
- the agent updates its policy or value estimates.
Q-learning is an off-policy temporal-difference method. It learns an estimate:
Q(s, a)
for the expected return of taking action a in state s.
The update is based on the best next action, regardless of the action actually selected by the exploration policy:
Q(s,a) <- Q(s,a) + alpha * (r + gamma * max_a' Q(s',a') - Q(s,a))
SARSA is on-policy. It updates using the action actually selected at the next state:
Q(s,a) <- Q(s,a) + alpha * (r + gamma * Q(s',a') - Q(s,a))
This makes it more conservative when exploration can be risky.

The maze examples show how reward shaping guides the agent toward the goal while discouraging invalid or undesirable moves.

Demo programs:
mazepath_finder
Dqn replaces a tabular Q-table with an MlpMatrixNN. It includes:
- replay buffer;
- random mini-batch sampling;
- frozen target network;
- epsilon-greedy action selection.
Demo:
dqn_maze