Reinforcement Learning (Q-Learning)
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
Platform Compatibility
Windows macOS LinuxCategories
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
Reinforcement Learning(Q-Learning)/
Version | Published | Release Notes | |
---|---|---|---|
1.0.0.0 |