def __init__(self, filename, max_steps, visualize=False): self.pyboy = PyBoy(filename, window_type="headless" if not visualize else "SDL2", window_scale=3, debug=visualize, game_wrapper=True) assert self.pyboy.cartridge_title() == "SUPER MARIOLAN" self.pyboy.set_emulation_speed(0) self.mario = self.pyboy.game_wrapper() self.mario_lives = None self.mario_size = 0 self.fitness_score = 0 self.previous_fitness_score = 0 self.previous_direction = 0 self._level_progress_max = 0 self.observation_space = (16, 20) self.action_space = [4] self.max_steps = max_steps self.pair_actions = {"5": 13, "3": 11, "4": 12, "0": 0} self.action_jump = [ WindowEvent.PRESS_BUTTON_A, WindowEvent.RELEASE_BUTTON_A ] self.action_direction = [ WindowEvent.PRESS_ARROW_LEFT, WindowEvent.PRESS_ARROW_RIGHT, 0 ]
def replay(ROM, replay, verify=True): pyboy = PyBoy(ROM, disable_input=True) pyboy.set_emulation_speed(0) with open(replay, 'rb') as f: recorded_input = json.loads(zlib.decompress(f.read()).decode('ascii')) # Filters out the blacklisted events recorded_input = list( map( lambda event_tuple: ( event_tuple[0], list(filter(lambda x: x not in event_filter, event_tuple[1])), # event_tuple[2] ), recorded_input)) frame_count = 0 next_event = recorded_input.pop(0) while recorded_input != []: if next_event[0] == frame_count: for e in next_event[1]: pyboy.send_input(e) # if verify: # assert verify_screen_image_np(pyboy, base64.b64decode(next_event[2].encode('utf8'))) next_event = recorded_input.pop(0) frame_count += 1 pyboy.tick() pyboy.stop(save=False)
def run_rom(rom): # logger.info(rom) pyboy = PyBoy(rom, window_type="dummy", window_scale=1, bootrom_file="ROMs/DMG_ROM.bin", disable_input=True) # pyboy = PyBoy("ROMs/DMG_ROM.bin", window_type="SDL2", window_scale=1, bootrom_file=rom, disable_input=True) pyboy.disable_title() pyboy.set_emulation_speed(0) serial_output = "" t = time.time() result = None while not pyboy.tick(): b = pyboy.get_serial() if b != "": serial_output += b t = time.time() if "Passed" in serial_output: result = ("Passed") break elif "Failed" in serial_output: result = (serial_output) break if time.time() - t > timeout: result = ("Timeout:\n" + serial_output) break pyboy.stop(save=False) return result
def main(): # Automatically bump to '-OO' optimizations if __debug__: os.execl(sys.executable, sys.executable, '-OO', *sys.argv) bootrom = "ROMs/DMG_ROM.bin" romdir = "ROMs/" scale = 3 # Verify directories if bootrom is not None and not os.path.exists(bootrom): print("Boot-ROM not found. Please copy the Boot-ROM to '%s'. Using replacement in the meanwhile..." % bootrom) bootrom = None if not os.path.exists(romdir) and len(sys.argv) < 2: print("ROM folder not found. Please copy the Game-ROM to '%s'".format(romdir)) exit() try: # Check if the ROM is given through argv if len(sys.argv) > 2: # First arg is SDL2/PyGame filename = sys.argv[2] else: filename = getROM(romdir) # Start PyBoy and run loop pyboy = PyBoy(sys.argv[1] if len(sys.argv) > 1 else None, scale, filename, bootrom) while not pyboy.tick(): pass pyboy.stop() except KeyboardInterrupt: print("Interrupted by keyboard") except Exception: traceback.print_exc()
def test_rom(rom): logger.info(rom) pyboy = PyBoy("dummy", 1, rom, "ROMs/DMG_ROM.bin") # pyboy = PyBoy("SDL2", 1, rom, "ROMs/DMG_ROM.bin") pyboy.disableTitle() pyboy.setEmulationSpeed(False) serial_output = "" t = time.time() result = None while not pyboy.tick(): b = pyboy.getSerial() if b != "": serial_output += b # print b, t = time.time() if "Passed" in serial_output: result = ("Passed") break elif "Failed" in serial_output: result = (serial_output) break if time.time() - t > timeout: result = ("Timeout:\n" + serial_output) break print(serial_output) pyboy.stop(save=False) return result
def test_start_level(self): pyboy = PyBoy(supermarioland_rom, window_type="dummy", game_wrapper=True) pyboy.set_emulation_speed(0) starting_level = (2, 1) env = pyboy.openai_gym(observation_type="minimal", action_type="toggle", world_level=starting_level) if env is None: raise Exception( "'env' is None. Did you remember to install 'gym'?") observation = env.reset() print(env.game_wrapper.world, starting_level) assert env.game_wrapper.world == starting_level env.game_wrapper.set_lives_left(0) env.step(4) # PRESS LEFT for _ in range(200): env.step(0) assert env.game_wrapper.time_left == 399 assert env.game_wrapper.world == starting_level
def pyboy(): pyboy = PyBoy(tetris_rom, window_type="headless", disable_input=True, game_wrapper=True) pyboy.set_emulation_speed(0) return pyboy
def __init__(self, args): self.locations = [] self.events = [ 'D5F3', 'D60D', 'D700', 'D70B', 'D70C', 'D70D', 'D70E', 'D710', 'D714', 'D72E', 'D751', 'D755', 'D75E', 'D773', 'D77C', 'D782', 'D790', 'D792', 'D79A', 'D7B3', 'D7D4', 'D7D8', 'D7E0', 'D7EE', 'D803', 'D85F' ] self.towns_visited = 0 self.event_tot = 0 self.badges = 0 self.owned_pokemon = 0 self.position = {} self.actions_since_moved = 0 self.pyboy = PyBoy( args.rom, window_type= "headless", # For unattended use, for example machine learning ) self.pyboy.disable_title() self.transform = transforms.Compose( [transforms.Resize(64), transforms.ToTensor()]) self.args = args self.action_space = 6 self.pyboy.set_emulation_speed(0) self.buffered_state = io.BytesIO() if args.save_state != "": self.pyboy.load_state(open(args.save_state, 'rb')) self.pyboy.save_state(self.buffered_state) else: for n in tqdm( range(4000)): # Move ahead the desired number of frames. self.pyboy.tick() if 1298 == n: self.pyboy.send_input(windowevent.PRESS_BUTTON_START) elif n == 1320: self.pyboy.send_input(windowevent.RELEASE_BUTTON_START) elif n > 1320 and n % 2 == 0: self.pyboy.send_input(windowevent.PRESS_BUTTON_A) elif n > 1320 and n % 2 != 0: self.pyboy.send_input(windowevent.RELEASE_BUTTON_A) self.pyboy.save_state(open('start_game.state', 'wb')) self.pyboy.save_state(self.buffered_state) self.position['x'] = self.pyboy.get_memory_value(0xd361) self.position['y'] = self.pyboy.get_memory_value(0xd362) self.pyboy.send_input(SCREEN_RECORDING_TOGGLE) self.pyboy.tick() frame = self.transform(self.pyboy.get_screen_image()) self.state_size = frame.size(-1) * frame.size(-2) * frame.size(-3)
def setup_pyboy(self): # load rom through PyBoy dir_path = os.path.dirname(os.path.realpath(__file__)) rom_dir = os.path.join(dir_path, 'roms') self.pyboy = PyBoy(os.path.join(rom_dir, 'Pokemon.gb')) # set up PyBoy screen support self.bot_sup = self.pyboy.botsupport_manager() self.scrn = self.bot_sup.screen() # minimize PyBoy window pyboy_handle = ctypes.windll.user32.FindWindowW(None, "PyBoy") ctypes.windll.user32.ShowWindow(pyboy_handle, 6)
def pokemon(): pyboy = PyBoy( 'roms/Pokemon-VersionBleue(France).gb', window_type="headless", # "SDL2" if hidden window_scale=3, debug=False, game_wrapper=True) pyboy.set_emulation_speed(0) # while not pyboy.tick(): # pass return pyboy
def __init__(self, rom_path, name, host, port, savestate, password): self.pyboy = PyBoy(rom_path) if savestate: file_like_object = open(savestate, "rb") self.pyboy.load_state(file_like_object) self.host = host self.port = port self.currMap = -1 self.x = 0 self.y = 0 self.rivalMap = -1 self.rivalX = 0 self.rivalY = 0 self.rivalFacing = 0 self.rivalSpriteNum = 15 self.prevmoFlags = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] self.rivalSprite = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] self.sprite = [] #initial dex self.pokedex = pokedexOwned([ self.pyboy.get_memory_value(t) for t in range(POKEDEX_RANGE_START, POKEDEX_RANGE_END + 1) ]) #list of wild pokemon locked out by opp self.lockedOutWilds = [] #initial badges self.badges = badgesOwned(self.pyboy.get_memory_value(BADGES_ACQUIRED)) #game options self.gameOptions = None #connect to server and send nickname self.Connect((self.host, self.port)) connection.Send({"action": "nickname", "nickname": name}) #reaaal basic passwording here connection.Send({ "action": "verifyPasswordCheckCapacity", "password": password })
def _abstractStart(self, gameROM, bootROM) -> None: """Start the PyBoy emulator. Parameters ---------- gameROM: str File path to the game ROM to use. bootROM: str File path to the boot ROM to use. """ self._pyboy = PyBoy(gameROM, default_ram_file=bootROM, window_type="headless") self._pyboy.set_emulation_speed(False)
def run_rom(args): rom, frame_limit = args pyboy = PyBoy(rom, window_type="dummy", window_scale=1, bootrom_file=utils.boot_rom, disable_input=True) pyboy.set_emulation_speed(0) serial_output = "" t = time.time() result = None frame_count = 0 while not pyboy.tick(): b = pyboy._serial() if b != "": serial_output += b t = time.time() if "Passed" in serial_output: result = ("Passed") break elif "Failed" in serial_output: result = (serial_output) break if frame_limit == -1 and time.time() - t > timeout: result = ("Timeout:\n" + serial_output) break elif frame_count == frame_limit: result = ("Frame limit reached:\n" + serial_output) break frame_count += 1 pyboy.stop(save=False) return result
def main(): argv = parser.parse_args() log_level(argv.log_level) logger.info( """ The Game Boy controls are as follows: | Keyboard key | GameBoy equivalant | | --- | --- | | Up | Up | | Down | Down | | Left | Left | | Right | Right | | A | A | | S | B | | Return | Start | | Backspace | Select | The other controls for the emulator: | Keyboard key | Emulator function | | --- | --- | | Escape | Quit | | D | Debug | | Space | Unlimited FPS | | Z | Save state | | X | Load state | | I | Toggle screen recording | | O | Save screenshot | | , | Rewind backwards | | . | Rewind forward | See "pyboy --help" for how to enable rewind and other awesome features! """ ) # Start PyBoy and run loop pyboy = PyBoy(argv.ROM, **vars(argv)) if argv.loadstate is not None: if argv.loadstate == INTERNAL_LOADSTATE: # Guess filepath from ROM path state_path = argv.ROM + ".state" else: # Use filepath given state_path = argv.loadstate valid_file_path(state_path) with open(state_path, "rb") as f: pyboy.load_state(f) while not pyboy.tick(): pass pyboy.stop() if argv.profiling: print("\n".join(profiling_printer(pyboy._cpu_hitrate())))
async def on_message(message): if message.author != client.user: if message.content.startswith(config.prefix): text = message.content[config.prefix_len:] if text.startswith("run"): game.gb = PyBoy("data/PokemonRouge.gb") game.bot_supp = game.gb.botsupport_manager() game.gb.set_emulation_speed(4) game.channel = message.channel game.pause = False await message.channel.send("Starting: " + game.gb.cartridge_title()) elif text.startswith("stop"): game.gb.stop() game.channel = None game.bot_supp = None game.gb = None game.pause = True elif text.startswith("pause"): game.gb.send_input(WindowEvent.PAUSE) game.pause = True elif text.startswith("unpause"): game.gb.send_input(WindowEvent.PAUSE) game.pause = False elif text.startswith("name"): await message.channel.send("Running: " + game.gb.cartridge_title()) elif text in input_list.keys() and message.channel == game.channel: game.gb.send_input(input_list[text])
def test_all_argv(): pyboy = PyBoy(any_rom, window_type="dummy", bootrom_file=utils.boot_rom, disable_input=True, hide_window=True) pyboy.tick() pyboy.send_input(windowevent.QUIT) pyboy.stop(save=False)
def test_disable_title(): # Simply tests, that no exception is generated pyboy = PyBoy(any_rom, window_type="dummy", disable_input=True, hide_window=True) pyboy.disable_title() pyboy.tick() pyboy.stop(save=False)
def main(): # Automatically bump to '-OO' optimizations # if __debug__: # os.execl(sys.executable, sys.executable, '-OO', *sys.argv) bootrom = "ROMs/DMG_ROM.bin" romdir = "ROMs/" scale = 3 # Verify directories if bootrom is not None and not os.path.exists(bootrom): print("Boot-ROM not found. Please copy the Boot-ROM to '%s'. Using replacement in the meanwhile..." % bootrom) bootrom = None if not os.path.exists(romdir) and len(sys.argv) < 2: print("ROM folder not found. Please copy the Game-ROM to '%s'".format(romdir)) exit() try: # Check if the ROM is given through argv if len(sys.argv) > 2: # First arg is SDL2/PyGame filename = sys.argv[2] else: filename = getROM(romdir) # Start PyBoy and run loop pyboy = PyBoy( filename, window_type=(sys.argv[1] if len(sys.argv) > 1 else None), window_scale=scale, bootrom_file=bootrom, autopause=argv_autopause, loadstate_file=argv_load_state_file, # Needs filename debugging=argv_debug, profiling=argv_profiling, record_input_file=argv_record_input_file, disable_input=argv_disable_input, ) while not pyboy.tick(): pass pyboy.stop() except KeyboardInterrupt: print("Interrupted by keyboard") except Exception: traceback.print_exc()
def test_mario_advanced(): pyboy = PyBoy(supermarioland_rom, window_type="dummy", game_wrapper=True) pyboy.set_emulation_speed(0) assert pyboy.cartridge_title() == "SUPER MARIOLAN" mario = pyboy.game_wrapper() mario.start_game(world_level=(3, 2)) lives = 99 mario.set_lives_left(lives) pyboy.tick() assert mario.score == 0 assert mario.lives_left == lives assert mario.time_left == 400 assert mario.world == (3, 2) assert mario.fitness == 10000 * lives + 6510 # A built-in fitness score for AI development pyboy.stop()
def __init__(self, game, window='SDL2', visible=False, colors=(0xfff6d3, 0xf9a875, 0xeb6b6f, 0x7c3f58), buttons_press_mode='toggle'): # Build game super().__init__() self._pyboy = PyBoy(game, window_type=window, color_palette=colors, disable_renderer=not visible) self._pyboy.set_emulation_speed(0) self._manager = self._pyboy.botsupport_manager() self._screen = self._manager.screen() self.actions = { 0: WindowEvent.PRESS_ARROW_UP, 1: WindowEvent.PRESS_ARROW_DOWN, 2: WindowEvent.PRESS_ARROW_LEFT, 3: WindowEvent.PRESS_ARROW_RIGHT, 4: WindowEvent.PRESS_BUTTON_A, 5: WindowEvent.PRESS_BUTTON_B, 6: WindowEvent.PRESS_BUTTON_SELECT, 7: WindowEvent.PRESS_BUTTON_START, 8: WindowEvent.RELEASE_ARROW_UP, 9: WindowEvent.RELEASE_ARROW_DOWN, 10: WindowEvent.RELEASE_ARROW_LEFT, 11: WindowEvent.RELEASE_ARROW_RIGHT, 12: WindowEvent.RELEASE_BUTTON_A, 13: WindowEvent.RELEASE_BUTTON_B, 14: WindowEvent.RELEASE_BUTTON_SELECT, 15: WindowEvent.RELEASE_BUTTON_START, 16: WindowEvent.PASS } self.action_space = Discrete(len(self.actions)) self.observation_space = Box(low=0, high=255, shape=(160, 144, 3), dtype=np.uint8) # Format : # {'addr':<address>, 'op':<operator>, 'reward':<reward>, 'val':<latest value>, 'lab':<label>} self._reward_rules = list() self._done_rules = list() self._refresh_values()
def test_observation_type_minimal(self): pyboy = PyBoy(supermarioland_rom, window_type="dummy", game_wrapper=True) pyboy.set_emulation_speed(0) env = pyboy.openai_gym(observation_type="minimal") observation = env.reset() expected_observation = np.zeros_like(observation) expected_observation[-4:-2, 4:6] = 1 # Mario expected_observation[-2:, :] = 3 # Ground expected_observation[-4:-2, 1:3] = 3 # Pipe expected_observation[9, 5] = 3 # ? Block print(observation) print(expected_observation) assert np.all(observation == expected_observation)
def eval_network(epoch, child_index, child_model): pyboy = PyBoy('SuperMarioLand.gb', game_wrapper=True) #, window_type="headless") pyboy.set_emulation_speed(3) mario = pyboy.game_wrapper() mario.start_game() # start off with just one life each mario.set_lives_left(0) run = 0 scores = [] fitness_scores = [] level_progress = [] time_left = [] # prev_action = np.asarray([1,0]) # do_action(prev_action, pyboy) while run < run_per_child: # do some things action = get_action(pyboy, mario, child_model) action = action.detach().numpy() action = np.where(action < np.max(action), 0, action) action = np.where(action == np.max(action), 1, action) action = action.astype(int) action = action.reshape((2, )) # do_action_multiple(prev_action,action,pyboy) do_action(action, pyboy) # prev_action = action # Game over: if mario.game_over() or mario.score == max_score: scores.append(mario.score) #fitness_scores.append(mario.fitness) fitness_scores.append( fitness_calc(mario.score, mario.level_progress, mario.time_left)) level_progress.append(mario.level_progress) time_left.append(mario.time_left) if run == run_per_child - 1: pyboy.stop() else: mario.reset_game() run += 1 child_fitness = np.average(fitness_scores) logger.info("-" * 20) logger.info("Iteration %s - child %s" % (epoch, child_index)) logger.info("Score: %s, Level Progress: %s, Time Left %s" % (scores, level_progress, time_left)) logger.info("Fitness: %s" % child_fitness) #logger.info("Output weight:") #weights = {} #for i, j in zip(feature_names, child_model.output.weight.data.tolist()[0]): # weights[i] = np.round(j, 3) #logger.info(weights) return child_fitness
def test_observation_type_compressed(self): pyboy = PyBoy(supermarioland_rom, window_type="dummy", game_wrapper=True) pyboy.set_emulation_speed(0) env = pyboy.openai_gym(observation_type="compressed") if env is None: raise Exception( "'env' is None. Did you remember to install 'gym'?") observation = env.reset() expected_observation = np.zeros_like(observation) expected_observation[-4:-2, 4:6] = 1 # Mario expected_observation[-2:, :] = 10 # Ground expected_observation[-4:-2, 1:3] = 14 # Pipe expected_observation[9, 5] = 13 # ? Block print(observation) print(expected_observation) assert np.all(observation == expected_observation)
def test_mario_basics(): pyboy = PyBoy(supermarioland_rom, window_type="dummy", game_wrapper=True) pyboy.set_emulation_speed(0) assert pyboy.cartridge_title() == "SUPER MARIOLAN" mario = pyboy.game_wrapper() mario.start_game(world_level=(1, 1)) assert mario.score == 0 assert mario.lives_left == 2 assert mario.time_left == 400 assert mario.world == (1, 1) assert mario.fitness == 0 # A built-in fitness score for AI development pyboy.stop()
def test_misc(): pyboy = PyBoy(any_rom, window_type="dummy", bootrom_file=boot_rom, disable_input=True, hide_window=True) pyboy.tick() pyboy.stop(save=False)
def eval_genome(genome, config): global max_fitness pyboy = PyBoy('SuperMarioLand.gb', game_wrapper=True) #, window_type="headless") pyboy.set_emulation_speed(0) mario = pyboy.game_wrapper() mario.start_game() # start off with just one life each mario.set_lives_left(0) run = 0 scores = [] fitness_scores = [] level_progress = [] time_left = [] # create NN from neat model = neat.nn.FeedForwardNetwork.create(genome, config) child_fitness = 0 while run < run_per_child: # do some things action = get_action_neat(pyboy, mario, model) action = np.asarray([np.mean(val) for val in action]) action = np.where(action < np.max(action), 0, action) action = np.where(action == np.max(action), 1, action) action = action.astype(int) action = action.reshape((2, )) do_action(action, pyboy) # Game over: if mario.game_over() or mario.score == max_score: scores.append(mario.score) fitness_scores.append( fitness_calc(mario.score, mario.level_progress, mario.time_left)) level_progress.append(mario.level_progress) time_left.append(mario.time_left) if run == run_per_child - 1: pyboy.stop() else: mario.reset_game() run += 1 child_fitness = np.average(fitness_scores) #logger.info("-" * 20) #logger.info("Iteration %s - child %s" % (epoch, child_index)) #logger.info("Score: %s, Level Progress: %s, Time Left %s" % (scores, level_progress, time_left)) #logger.info("Fitness: %s" % child_fitness) return child_fitness
def loadCartridge(filePath, quiet=True, emSpd=1): pyboy = PyBoy(filePath, window_type="headless" if quiet else "SDL2", window_scale=3, debug=not quiet, game_wrapper=True) pyboy.set_emulation_speed(emSpd) pyboy.cartridge_title() == "SUPER MARIOLAN" return pyboy
def test_shonumi(rom): # Has to be in here. Otherwise all test workers will import this file, and cause an error. shonumi_dir = "GB Tests" if not os.path.isdir(shonumi_dir): print( urllib.request.urlopen( "https://pyboy.dk/mirror/SOURCE.GBTests.txt").read()) shonumi_data = io.BytesIO( urllib.request.urlopen( "https://pyboy.dk/mirror/GB%20Tests.zip").read()) with ZipFile(shonumi_data) as _zip: _zip.extractall(shonumi_dir) pyboy = PyBoy(rom, window_type="headless", color_palette=(0xFFFFFF, 0x999999, 0x606060, 0x000000)) pyboy.set_emulation_speed(0) # sprite_suite.gb # 60 PyBoy Boot # 23 Loading # 50 Progress to screenshot for _ in range(60 + 23 + 50): pyboy.tick() png_path = Path(f"test_results/{rom}.png") png_path.parents[0].mkdir(parents=True, exist_ok=True) image = pyboy.botsupport_manager().screen().screen_image() old_image = PIL.Image.open(png_path) old_image = old_image.resize(image.size, resample=PIL.Image.NEAREST) diff = PIL.ImageChops.difference(image, old_image) if diff.getbbox() and not os.environ.get("TEST_CI"): image.show() old_image.show() diff.show() assert not diff.getbbox(), f"Images are different! {rom}" pyboy.stop(save=False)
def initialize_emulator(emu_conf={"gamerom": get_games_list()[0]}): gamerom = "roms/" + emu_conf["gamerom"] if "bootrom_file" in emu_conf: bootrom_file = emu_conf["bootrom_file"] else: bootrom_file = None if "profiling" in emu_conf: profiling = emu_conf["profiling"] else: profiling = False if "disable_renderer" in emu_conf: disable_renderer = emu_conf["disable_renderer"] else: disable_renderer = False if "sound" in emu_conf: sound = emu_conf["sound"] else: sound = True if "color_palette" in emu_conf: color_palette = rgb2bit(emu_conf["color_palette"]) else: color_palette = rgb2bit("Blue") if "gamespeed" in emu_conf: gamespeed = emu_conf["gamespeed"] else: gamespeed = 0 kwargs_pyboy = { "bootrom_file": bootrom_file, "profiling": profiling, "disable_renderer": disable_renderer, "sound": sound, "color_palette": color_palette } gameboy = PyBoy(gamerom, **kwargs_pyboy) gameboy.set_emulation_speed(gamespeed) print(gameboy.cartridge_title(), "speed:", gamespeed) if disable_renderer: gameboy.stop(save=False) return gameboy
def test_profiling(): pyboy = PyBoy(default_rom, window_type="dummy", bootrom_file=boot_rom, profiling=True) pyboy.set_emulation_speed(0) pyboy.tick() hitrate = pyboy._cpu_hitrate() CHECK_SUM = 7524 assert sum( hitrate ) == CHECK_SUM, "The amount of instructions called in the first frame of the boot-ROM has changed" assert list(main.profiling_printer(hitrate)) == [ "17c BIT 7,H 2507", " 32 LD (HL-),A 2507", " 20 JR NZ,r8 2507", " af XOR A 1", " 31 LD SP,d16 1", " 21 LD HL,d16 1", ], "The output of the profiling formatter has changed. Either the output is wrong, or the formatter has changed." pyboy.stop(save=False)
print ("Boot-ROM not found. Please copy the Boot-ROM to '%s'. Using replacement in the meanwhile..." % bootROM) bootROM = None if not os.path.exists(ROMdir) and len(sys.argv) < 2: print ("ROM folder not found. Please copy the Game-ROM to '%s'" % ROMdir) exit() try: # Check if the ROM is given through argv if len(sys.argv) > 1: # First arg is SDL2/PyGame filename = sys.argv[1] else: filename = getROM(ROMdir) # Start PyBoy and run loop pyboy = PyBoy('SDL2', 3, filename, bootROM) pyboy.setEmulationSpeed(False) frame = 0 first_brick = False view = pyboy.getTileView(False) for _ in range(5282): # Enough frames to get a "Game Over". Otherwise do: `while not pyboy.tick():` pyboy.tick() print ("frame:", frame) # Start game. Just press Start and A when the game allows us. # The frames are not 100% accurate. if frame == 144: pyboy.sendInput(windowevent.PRESS_BUTTON_START) elif frame == 145: pyboy.sendInput(windowevent.RELEASE_BUTTON_START) elif frame == 152: