Prepare the data
Specify a simulated environment, legal actions, rewards and episode termination conditions.
Explore an action. Learn from its reward.
A bandit is a compact introduction to learning from rewards. Extending it to a small stateful environment introduces transitions, delayed reward and policies that depend on state.
Learning concept · Not a validated service
A bandit is a compact introduction to learning from rewards. Extending it to a small stateful environment introduces transitions, delayed reward and policies that depend on state.
A possible application for reinforcement-learning instructors: Help learners compare immediate-reward bandits with stateful decision problems. This extension is not delivered by the supplied starter.
Specify a simulated environment, legal actions, rewards and episode termination conditions.
Start with the supplied bandit, then implement tabular Q-learning in a tiny grid world.
Compare returns across seeds against a random policy and inspect failure states.
Keep the agent in simulation and provide an episode replay with reward explanations.
The supplied NumPy simulation uses four fixed Bernoulli reward rates and an epsilon-greedy policy with epsilon 0.1 over 2,000 rounds. It prints action counts, estimated reward rates and total reward.
for step in range(1, 2001):
if rng.random() < epsilon:
action = rng.integers(len(true_reward_rates))
else:
action = int(np.argmax(estimated_values))
reward = 1 if rng.random() < true_reward_rates[action] else 0
action_counts[action] += 1
total_reward += reward
estimated_values[action] += (
reward - estimated_values[action]
) / action_counts[action]The source is a stateless bandit; it does not implement Q-learning or a stateful environment. The environment has stationary rewards and no state transitions. A single seeded run does not establish policy quality; compare regret across repeated simulations before considering any live experiment.
Proposed extension: Help learners compare immediate-reward bandits with stateful decision problems.
This is a potential application pathway, not a delivered product. The supplied starter does not implement this service or validate it with real users.
Networkers Home runs this topic inside its AI Engineer Course, with placement support and hands-on labs.