我是靠谱客的博主 英俊花瓣,这篇文章主要介绍q learning matlab,用Matlab实现简单的Q-learning算法(学习走出房间),现在分享给大家,希望可以做个参考。

看到一个简单有趣的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内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(76)

评论列表共有 0 条评论

立即
投稿
返回
顶部