我正在尝试制作一个简单的python代理,该代理可以检测游戏中的转身并相应地向左或向右转。但是,我对于如何使代理观察屏幕以及如何在我的代码中实现代理感到困惑。
我对机器学习和体育运动还是很陌生。我在下面有使用健身房的基本布局,
import gym
import universe
env = gym.make(‘flashgames.NeonRace-v0’)
env.configure(remotes=1)
observation_n = env.reset()
while True:
action_n = [[('KeyEvent', 'ArrowUp', True)] for ob in observation_n]
#Your agent here
observation_n, reward_n, done_n, info = env.step(action_n)
env.render()
下面是代理的布局,
def getAgent():
""" The daemon searches for this callable function to create a new agent with """
return MyAgent()
class MyAgent(object):
def __init__(self):
""" standard object init """
self.done = False
def run(self, messaging, args):
""" Call by daemon when the agent is to start running """
while not self.done:
pass
def stop(self):
""" Called by daemon when the thread is requested to stop """
self.done = True
我将开始执行代码,但是每当要观察屏幕时,我都会卡住。
答案 0 :(得分:1)
您已经在env.reset()和env.step(action_n)的返回中获得了观察结果。代理应采取观察并使用某种监督学习方法(例如深度神经网络)来预测观察的作用。这是您所缺少的吗?