概述
看到一个简单有趣的Q learning例子,写了段matlab代码实现一下。有兴趣的请先阅读原文 链接
dbstop if error%stop at the error if it happens
%Initialization
episode_num = 100;%Iteration time of exploration
state_num = 6;%Room number (including the hall)
gamma = 0.8;%discount factor
%100: Arrival the hall
Reward_table = [
-1 -1 -1 -1 0 -1; %1
-1 -1 -1 0 -1 100; %2
-1 -1 -1 0 -1 -1; %3
-1 0 0 -1 0 -1; %4
0 -1 -1 0 -1 100; %5
-1 0 -1 -1 0 100 %6
];
Q_table = zeros(state_num, state_num);
final_state = 6;
for i = 1:episode_num
%Randomly start in a room
current_state = randperm(state_num,1);
while current_state ~= final_state
%Get the possible actions based on the current status
Action_option_list = find(Reward_table(current_state,:)>-1);
%Rando
最后
以上就是英俊花瓣为你收集整理的q learning matlab,用Matlab实现简单的Q-learning算法(学习走出房间)的全部内容,希望文章能够帮你解决q learning matlab,用Matlab实现简单的Q-learning算法(学习走出房间)所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复