Reinforcement Learning (Q-Learning)

Version 1.0.0.0 (9.94 KB) by Asad Ali
Demonstrates Reinforcement Learning (Q-Learning) algorithm using a maze
5.1K Downloads
Updated 21 Jun 2017

View License

This code demonstrates the reinforcement learning (Q-learning) algorithm using an example of a maze in which a robot has to reach its destination by moving in the left, right, up and down directions only. At each step, based on the outcome of the robot action it is taught and re-taught whether it was a good move or not eventually the whole process is repeated time and again until it reaches its destination. At this point the process will start again so that what ever has been learned can be verified and unnecessary moves made during the first pass can be forgotten and so on. It is good tutorial example for situations in which learning has to be done on the go i.e. without the use of training examples. Can be used in games to learn and improve the competitive capability of AI algorithm with that of human players and several other scenarios.
On small maze the convergence will be fast where as on large maze convergence can take some time. You can improve convergence speed by modifying the code to make Q-learning efficient.

There are four m-files
QLearning_Maze_Walk.m - demonstrates the working of Q-learning algorithm on a selected maze
Random_Maze_Walk.m - demonstrates the working of random selection for comparison
Read_Maze.m - will read the maze provided as input and translate into numeric representation for processing
Textscanu.m - reads the raw maze text file

Two maze files are included:
maze-9-9.txt
maze-61-21.txt

Cite As

Asad Ali (2024). Reinforcement Learning (Q-Learning) (https://www.mathworks.com/matlabcentral/fileexchange/63407-reinforcement-learning-q-learning), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2010a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Labyrinth problems in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.0.0