Skip to content

Commit f935891

Browse files
authored
Revise README
Expanded README to include project overview, problem description, solution details, project structure, building instructions, and license information.
1 parent f00000f commit f935891

1 file changed

Lines changed: 70 additions & 5 deletions

File tree

README.md

Lines changed: 70 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,72 @@
1-
## Quick Start
1+
# Taxi Cab Problem — Reinforcement Learning
22

3-
```console
4-
$ cc -o nob nob.c
5-
$ ./nob
6-
$ ./main
3+
A Q-learning agent that learns to navigate a taxi in a 5×5 grid world, pick up passengers, and drop them at their destination.
4+
5+
**[▶ Live Demo](https://rednayan.github.io/rl-taxi-cab-problem/)**
6+
7+
![Taxi Environment](https://gymnasium.farama.org/_images/taxi.gif)
8+
9+
## The Problem
10+
11+
Based on the classic [Taxi-v3](https://gymnasium.farama.org/environments/toy_text/taxi/) environment. The taxi must:
12+
13+
1. Navigate a 5×5 grid with walls
14+
2. Pick up a passenger from one of 4 locations (R, G, Y, B)
15+
3. Drop them off at another location
16+
4. Do this as efficiently as possible
17+
18+
**Rewards:**
19+
- +20 for successful drop-off
20+
- -1 for each step (encourages efficiency)
21+
- -10 for illegal pickup/drop-off attempts
22+
23+
**State space:** 500 states (5×5 grid × 5 passenger locations × 4 destinations)
24+
25+
**Actions:** 6 (Up, Down, Left, Right, Pickup, Drop)
26+
27+
## The Solution
28+
29+
This project implements **Q-learning**, a model-free reinforcement learning algorithm. The agent learns a Q-table mapping state-action pairs to expected rewards through trial and error.
30+
31+
```
32+
Q(s,a) ← Q(s,a) + α[r + γ·max(Q(s',a')) - Q(s,a)]
733
```
34+
35+
**Hyperparameters:**
36+
- Learning rate (α): 0.1
37+
- Discount factor (γ): 0.99
38+
- Exploration rate (ε): 0.1
39+
- Episodes: 5000
40+
41+
After training, the agent learns the optimal policy and consistently solves the task in minimal steps.
42+
43+
## Project Structure
44+
45+
```
46+
├── main.c # Training loop, visualization, Q-learning
47+
├── taxi.c # Environment logic (step, reset, rewards)
48+
├── taxi.h # Environment struct and function declarations
49+
```
50+
51+
## Building Locally
52+
53+
Requires [raylib](https://www.raylib.com/) for visualization.
54+
55+
- **Linux:** raylib 5.5 is included in the repo — no installation needed.
56+
57+
- **For other systems:** download the source code of [raylib](https://github.com/raysan5/raylib.git)
58+
59+
```bash
60+
# manually with gcc
61+
gcc -o taxi main.c taxi.c -lraylib -lGL -lm -lpthread
62+
63+
# or Using the nob build system
64+
# update the `nob.c` file with appropiate file path for a `nob` build.
65+
./nob
66+
67+
68+
```
69+
70+
## License
71+
72+
MIT

0 commit comments

Comments
 (0)