Skip to content

koesan/q-learning

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 

Repository files navigation

Q-Learning Maze Solver

Teaching an AI agent to navigate through a maze using reinforcement learning

Python NumPy Q-Learning

Maze Map

📎 Live Demo - Canlı Demo

Hugging Face


English | Türkçe


English

🎮 What is this?

A simple reinforcement learning project where an AI agent learns to find the shortest path through an 11×11 maze using Q-Learning. The agent explores the maze, learns from rewards, and discovers the optimal route!

✨ How it works

  1. Maze Environment - 11×11 grid with walls (-100), paths (-1), and goal (+100)
  2. Agent Exploration - Random start position, explores with epsilon-greedy strategy
  3. Learning - Updates Q-table based on rewards and future states
  4. Optimal Path - After 1000 episodes, finds shortest route to exit

🧠 Q-Learning Basics

  • State: Current position in maze
  • Action: Move up, down, left, or right
  • Reward: +100 for goal, -1 for path, -100 for walls
  • Q-Table: Learns value of each action at each position

🚀 Quick Start

python qlearning.py

That's it! Watch the agent learn and find the optimal path.

⚙️ Parameters

lr = 0.9           # Learning rate
gamma = 0.9        # Discount factor
epsilon = 0.9      # Exploration rate
episodes = 1000    # Training iterations

📊 Results

The agent successfully learns the shortest path from start [9,1] to goal [3,10] after training!


Turkish

🎮 Bu Nedir?

Bir yapay zeka ajanının Q-Learning kullanarak 11×11'lik bir labirentten en kısa yolu bulmasını öğrendiği basit bir pekiştirmeli öğrenme projesi. Ajan labirenti keşfeder, ödüllerden öğrenir ve optimal rotayı keşfeder!

✨ Nasıl Çalışır

  1. Labirent Ortamı - Duvarlar (-100), yollar (-1) ve hedef (+100) olan 11×11 ızgara
  2. Ajan Keşfi - Rastgele başlangıç, epsilon-greedy stratejisi ile keşif
  3. Öğrenme - Ödüllere ve gelecek durumlara göre Q-tablosunu günceller
  4. Optimal Yol - 1000 bölümden sonra çıkışa en kısa yolu bulur

🧠 Q-Learning Temelleri

  • Durum (State): Labirentteki mevcut konum
  • Eylem (Action): Yukarı, aşağı, sola veya sağa hareket
  • Ödül (Reward): Hedef için +100, yol için -1, duvarlar için -100
  • Q-Tablosu: Her konumdaki her eylemin değerini öğrenir

🚀 Hızlı Başlangıç

python qlearning.py

Bu kadar! Ajanın öğrenmesini ve optimal yolu bulmasını izleyin.

⚙️ Parametreler

lr = 0.9           # Öğrenme oranı
gamma = 0.9        # İndirim faktörü
epsilon = 0.9      # Keşif oranı
episodes = 1000    # Eğitim tekrarı

📊 Sonuçlar

Ajan eğitim sonrası başlangıç [9,1] noktasından hedef [3,10] noktasına en kısa yolu başarıyla öğrenir!

About

Q-Learning maze solver - AI agent finds shortest path | Q-Learning labirent çözücü - Yapay zeka ajanı en kısa yolu buluyor

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages