An example of a successful Q learning algorithm. This project was made as part of my Intelligent Systems Module. This Example implements a Q-learning algorithm on a grid world of varying states and a goal (marked G on state 2) as shown by the diagram below.
To run a single episode, i.e. one traversal of the world from start state to goal, run the command:
qLearningEpisode(qTableInit())This will return the number of steps taken. To run a trial, in this case 100 episodes, use the command:
qLearningTrial()This will return an array containing the number of steps taken for each episode. This can be plotted onto a graph with the command:
plot(qLearningTrial())To run an experiment, i.e, 50 trials, run the command:
qLearningExperiment()This function returns a 2D array containing the number of steps taken for each episode in each trial. The function also plots the mean and standard deviation of the number of steps taken for each episode across trials.
This Example also has some unit tests which you can run with the command
runtests('qLearningTest')