gina's portfolio
Back to featured projects

Reinforcement learning

Pirate Intelligent Agent

I created an intelligent agent that learns how to navigate a maze and locate hidden treasure. The project uses deep Q-learning, replay memory, reward-based decisions, and an epsilon-greedy strategy to improve the agent's behavior through repeated training.

  • Python
  • Keras
  • Deep Q-Learning
  • Replay Memory
  • Epsilon-Greedy
  • Reinforcement Learning
Pirate intelligent agent following a glowing decision path through an island maze toward treasure

Learning a path through experience

The agent explores different routes, receives feedback from the environment, and gradually favors decisions that lead toward the treasure.

Overview

Teaching an agent without prescribing every move

Instead of programming one fixed solution, I created an environment where the agent could learn from successful and unsuccessful choices. This demonstrates how reinforcement learning can discover useful behavior through interaction, feedback, and iteration.

Project goal

Reach the treasure reliably

The objective was to train an agent that could move through the maze, avoid unproductive actions, and increasingly select a successful route as its experience accumulated.

Learning cycle

Observe, act, learn, and repeat

01

Observe the state

The agent reads the current maze configuration and its position relative to available movement options.

02

Choose an action

An epsilon-greedy policy balances exploratory moves with actions predicted to provide the highest value.

03

Receive a reward

The environment evaluates the move, rewarding progress and successful treasure discovery while discouraging ineffective actions.

04

Update the strategy

Stored experiences are sampled from replay memory and used to improve the neural network’s Q-value estimates.

Agent design

Connecting the maze to a neural decision model

State representation

The maze state provides the model with the information needed to evaluate legal movement choices and future rewards.

Action space

The agent chooses among valid directional movements as it attempts to reach the goal.

Reward system

Reward-based feedback helps the agent distinguish useful progress from inefficient or unsuccessful movement.

Q-value approximation

A Keras neural network estimates the long-term value of available actions instead of relying on a fixed lookup table.

Exploration strategy

Balancing discovery with learned behavior

The epsilon-greedy strategy lets the agent explore random actions early in training while still using the model's strongest predictions. As training continues, exploration can decrease so the agent relies more heavily on what it has learned.

Replay memory

Learning from a broader range of experiences

Replay memory stores previous state transitions and samples them during training. Reusing varied experiences reduces dependence on the most recent sequence of moves and supports more stable model updates.

Training process

Improving performance across repeated episodes

01

Reset the maze and place the pirate agent at the starting position

02

Represent the current environment as a state the model can evaluate

03

Select an exploratory or learned action with the epsilon-greedy policy

04

Store the state, action, reward, and next state in replay memory

05

Train the Keras model on sampled experiences

06

Repeat episodes until the agent develops a more reliable route to the treasure

Evaluation

Measuring useful learned behavior

  • Whether the agent reaches the treasure successfully
  • How reliably it completes the maze across repeated episodes
  • Whether learned actions replace random exploration over time
  • How replay-memory training affects stability and convergence

Challenge & solution

Preventing random exploration from dominating

A learning agent needs enough exploration to discover successful routes, but excessive randomness prevents consistent behavior. I used epsilon-greedy action selection with repeated replay-memory training to shift the balance gradually from exploration toward informed decisions.

Project outcome

An adaptive agent that improves through experience

The project demonstrates my ability to connect reinforcement learning concepts with a functioning Python environment, build a neural decision model in Keras, manage training experiences, and reason about exploration, rewards, and learned behavior.