本文整理汇总了Python中env.Env.print_map_with_reprint方法的典型用法代码示例。如果您正苦于以下问题:Python Env.print_map_with_reprint方法的具体用法?Python Env.print_map_with_reprint怎么用?Python Env.print_map_with_reprint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类env.Env
的用法示例。
在下文中一共展示了Env.print_map_with_reprint方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Env
# 需要导入模块: from env import Env [as 别名]
# 或者: from env.Env import print_map_with_reprint [as 别名]
if (np.random.uniform() > 1 - EPSILON) or ((Q[state, :] == 0).all()):
action = np.random.randint(0, 4) # 0~3
else:
action = Q[state, :].argmax()
return action
e = Env()
Q = np.zeros((e.state_num, 4))
with output(output_type="list", initial_len=len(e.map), interval=0) as output_list:
for i in range(100):
e = Env()
action = epsilon_greedy(Q, e.present_state)
while (e.is_end is False) and (e.step < MAX_STEP):
state = e.present_state
reward = e.interact(action)
new_state = e.present_state
new_action = epsilon_greedy(Q, e.present_state)
Q[state, action] = (1 - ALPHA) * Q[state, action] + \
ALPHA * (reward + GAMMA * Q[new_state, new_action])
action = new_action
e.print_map_with_reprint(output_list)
time.sleep(0.1)
for line_num in range(len(e.map)):
if line_num == 0:
output_list[0] = 'Episode:{} Total Step:{}, Total Reward:{}'.format(i, e.step, e.total_reward)
else:
output_list[line_num] = ''
time.sleep(2)