本文整理汇总了Python中ale_python_interface.ALEInterface.getRAM方法的典型用法代码示例。如果您正苦于以下问题:Python ALEInterface.getRAM方法的具体用法?Python ALEInterface.getRAM怎么用?Python ALEInterface.getRAM使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ale_python_interface.ALEInterface
的用法示例。
在下文中一共展示了ALEInterface.getRAM方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pyrlcade_environment
# 需要导入模块: from ale_python_interface import ALEInterface [as 别名]
# 或者: from ale_python_interface.ALEInterface import getRAM [as 别名]
class pyrlcade_environment(object):
def init(self,rom_file,ale_frame_skip):
self.ale = ALEInterface()
self.max_frames_per_episode = self.ale.getInt("max_num_frames_per_episode");
self.ale.set("random_seed",123)
self.ale.set("disable_color_averaging",1)
self.ale.set("frame_skip",ale_frame_skip)
self.ale.loadROM(rom_file)
self.legal_actions = self.ale.getMinimalActionSet()
ram_size = self.ale.getRAMSize()
self.ram = np.zeros((ram_size),dtype=np.uint8)
self.ale.getRAM(self.ram)
self.state = self.ale.getRAM(self.ram)
def reset_state(self):
self.ale.reset_game()
def set_action(self,a):
self.action = a
def step(self):
self.reward = self.ale.act(self.action)
is_terminal = self.ale.game_over()
return is_terminal
def get_state(self):
self.ale.getRAM(self.ram)
return self.ram
def get_reward(self):
return self.reward
示例2: while
# 需要导入模块: from ale_python_interface import ALEInterface [as 别名]
# 或者: from ale_python_interface.ALEInterface import getRAM [as 别名]
#get atari screen pixels and blit them
numpy_surface = np.frombuffer(game_surface.get_buffer(),dtype=np.int32)
ale.getScreenRGB(numpy_surface)
logger.log(a, TYPE_ACTION, cur_time)
#if cur_time %2 == 0:
logger.log(numpy_surface, TYPE_SCREEN, cur_time)
del numpy_surface
screen.blit(pygame.transform.scale2x(game_surface),(0,0))
#get RAM
ram_size = ale.getRAMSize()
ram = np.zeros((ram_size),dtype=np.uint8)
ale.getRAM(ram)
#Display ram bytes
font = pygame.font.SysFont("Ubuntu Mono",32)
text = font.render("RAM: " ,1,(255,208,208))
screen.blit(text,(330,10))
font = pygame.font.SysFont("Ubuntu Mono",25)
height = font.get_height()*1.2
line_pos = 40
ram_pos = 0
while(ram_pos < 128):
ram_string = ''.join(["%02X "%ram[x] for x in range(ram_pos,min(ram_pos+16,128))])
text = font.render(ram_string,1,(255,255,255))
screen.blit(text,(340,line_pos))