in kb_agent.py [0:0]
def __init__(self, config):
self.config = config
self.command_dict = {
'\x1b[A': 'forward',
'w': 'up',
's': 'down',
'a': 'tleft',
'd': 'tright',
'e': 'interact',
}
self.config.defrost()
self.config.DEBUG = True
self.config.NUM_PROCESSES = 1
self.config.freeze()
self.envs = construct_envs(self.config, get_env_class(self.config.ENV_NAME))
self.observation = self.envs.reset()[0]
self.act_to_idx = collections.defaultdict(lambda: -1)
self.act_to_idx.update({act:idx for idx, act in enumerate(self.envs.call_at(0, 'get_actions'))})
sz = 300
N = 5
center = ((sz//N)*(N//2), (sz//N)*(N+1)//2)
self.center_box = [center[0], center[0], center[1], center[1]]
colors = {'green':[7, 212, 0], 'yellow':[255, 255, 0]}
colors = {color: torch.Tensor(colors[color]).unsqueeze(1)/255 for color in colors}
self.colors = colors
self.interactions = ['take', 'put', 'open', 'close', 'toggle-on', 'toggle-off', 'slice']
self.act_to_channel = {act: idx for idx, act in enumerate(self.interactions)}
self.render()
print ('KB controller set up.')
print ('↑: move forward, look: wsad, action: e')