Q学习走迷宫MATLAB代码.docVIP

  • 6
  • 0
  • 约小于1千字
  • 约 2页
  • 2020-12-13 发布于浙江
  • 举报
gamma = 0.4; %%设置初值 Q = zeros (6, 6); R = [-1 -1 -1 -1 0 -1; -1 -1 -1 0 -1 100; -1 -1 -1 0 -1 -1; -1 0 0 -1 0 -1; 0 -1 -1 0 -1 100; -1 0 -1 -1 0 100]; now = 2; seq = []; for now = 1:1:6 for i = 0:1:20 %%打乱路径顺序,选取随机的路径 rcolumn = R (now, :); rcolumn (rcolumn == -1) = []; num = randperm(size(rcolumn,2)); next = find (R (now,:) == rcolumn (num(1)), 1); seq = [seq next]; Qmax = max (Q(next,:));%%更新Q函数 Q (now, next) = R (now, next) + gamma * Qmax gamma = gamma*0.99;%%由随即策略渐渐变为随机策略

文档评论(0)

1亿VIP精品文档

相关文档