All projects

AI & ML / UCT · CSC3022 / 2024

Learning to navigate Four Rooms

Explore state, reward and sequential decisions through tabular Q-learning agents collecting packages across deterministic and stochastic rooms.

PythonQ-learningNumPy
Original Four Rooms agent path in a room grid

UCT / COURSE CONTEXT / 2024

CSC3022F · C++ and Machine Learning

C++ language and memory-model foundations followed by Python-based machine-learning implementation.

Science handbook · 2024

ENGINEERING PERSPECTIVE

Inside the work

Explore sequential decision-making: a move changes both position and collection progress, and an immediate reward must be weighed against later rewards. Three scenarios make state design and termination visible.

NumPy / Python
Store and update tabular state-action values in submitted scenario agents.
Supplied FourRooms environment
Grid transitions, package placement and path output; environment authorship is not claimed.
STEP 1 / 3

Encode the situation

Represent the grid position and scenario-specific collection state in the table index.

Source-derived walkthrough

What it is

Three submitted agents explore single, multiple and ordered package collection in a supplied Four Rooms environment.

Why it was built

Explore how state-action values can drive package collection in deterministic and stochastic room transitions.

My contribution

Submitted scenario agents and Q-table/reward logic; the FourRooms environment is supplied teaching code. Environment redistribution is held pending permission.

How it works

Use NumPy state-action tables, reward shaping and Q-value updates. Actions are greedy argmax selections; stochastic environment transitions provide a separate source of randomness.

  1. 01Grid state
  2. 02Greedy action
  3. 03Transition / reward
  4. 04Q-value update
  5. 05Path plot

Technical implementation

  • NumPy stores state-action values. Scenario variants change package-count/order objectives and reward handling.
  • The agent chooses greedy argmax actions; stochastic transitions in the environment are distinct from epsilon-greedy exploration, which is not claimed here.
  • The Q update combines immediate reward with discounted next-state values. State bookkeeping and terminal updates need care when package status changes.
  • A post-project wrapper bounds runtime and writes regenerated paths separately from the retained six original plots.

Inside the agent’s path

ACTUAL RECORDED AGENT / SEED42

STATE(1, 5)
ACTIONSTART
PACKAGES LEFT1
REWARD SUM0
LAST REWARD—
Reduced motion · transitions off

0 / 15 · Recorded completed episode

Fresh 2026 execution of original Scenario1 after its training loop. Greedy actions; stochastic environment may substitute another action with 20% probability. Default mode uses genuine stored transitions, not live browser training. Rewards: blocked −15, package +80, other move −1. One retained run per mode is not a success-rate evaluation.

Q(s,a)←(1−α)Q(s,a) + α[r + γ max Q(s′,a′)]

Source update equation. Individual Q values were not retained and are not fabricated.

Visual evidence

Original scenario 2 package-collection path
Original submitted scenario 2 path.
Original stochastic scenario 3 path
Original stochastic scenario 3 path; not a success-rate benchmark.

Results & evidence

  • Six original deterministic/stochastic path images are retained.
  • A bounded launcher isolates fresh generated paths from historical evidence.

Engineering challenges

A coordinate alone may not capture collection progress. The original loops, state stride and terminal-update behaviour constrain what the path evidence can establish.

Scope & limitations

Bookkeeping, terminal updates and unbounded loops can affect completion. A successful single run is not a convergence or optimality result. No invented success-rate metric is included.

What I learned

The practical importance of state design, exploration, reward shaping and termination in reinforcement learning.

What I would improve now

Review Markov state encoding, add explicit exploration and compare seeded completion rates across scenarios. Do not infer convergence from a successful path.

NEXT PROJECTStructure inside grayscale images