matplotlib 均值_用matplotlib绘制tictactoe游戏Agent的均值学习曲线

我已经编写了一个Q学习代理,它可以和一个随机的玩家玩井字游戏。 我想玩这个游戏20次,并用Matplotlib绘制一个单一的均值学习曲线。 第一个for循环玩游戏20次,并产生一个numpy.ndarrays列表。 如何获得平均报酬,我可以绘制成一条曲线? 下面是我到目前为止所做的工作:lines = []

#play tictactoe 20 times

for i in range(0, 20):

# Instantiate environment

environment = tictactoe.Tictactoe(verbose=True)

# play the game which returns the rewards gained in a number of episodes

line = play_tictactoe(environment,

player_o=player_o,

player_x=player_x,

episodes=m)

#line is a numpy.ndarray

lines.append(line)

for j in lines:

avg_line = #calculate the single mean learning curve (performance of the 20 agents)

x = np.arange(0, len(line))

fig, (ax2) = plt.subplots(1,1)

ax2.plot(x, avg_line, color="red", label="Q-Agent")

ax2.set_title("The mean performance of 20 Q-Learning Agents")

ax2.set_xlabel('Episodes')

ax2.set_ylabel('Rewards')

plt.legend()

plt.show()

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值