本文整理汇总了Python中agent.Agent.take_action方法的典型用法代码示例。如果您正苦于以下问题:Python Agent.take_action方法的具体用法?Python Agent.take_action怎么用?Python Agent.take_action使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类agent.Agent
的用法示例。
在下文中一共展示了Agent.take_action方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: open
# 需要导入模块: from agent import Agent [as 别名]
# 或者: from agent.Agent import take_action [as 别名]
import json
with open('API.json') as api:
data = json.load(api)
env = gym.make('FrozenLake-v0')
env.monitor.start('/tmp/frozenlake-experiment-9')
observation = env.reset()
action_space = env.action_space
observation, reward, done, info = env.step(action_space.sample())
agent = Agent(observation, reward, info, action_space.sample(), action_space)
num_episodes = 5000
for i_episode in range(num_episodes):
observation = env.reset()
done = False
t = 0
while not done:
env.render()
action = agent.take_action()
(observation, reward, done, info) = env.step(action)
agent.update(observation, reward, info, action, action_space)
t = t + 1
if done:
break
print("Episode finished after {} timesteps".format(t+1))
env.monitor.close()
gym.scoreboard.api_key = data["api_key"]
gym.upload('/tmp/frozenlake-experiment-9')