Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
np_in_mario_tiles = np.vectorize(lambda x: x in base_scripts)
# Apparantly that address is for lives left
# https://datacrystal.romhacking.net/wiki/Super_Mario_Land:RAM_map
ADDR_LIVES_LEFT = 0xDA15
ADDR_LIVES_LEFT_DISPLAY = 0x9806
ADDR_WORLD_LEVEL = 0xFFB4
ADDR_WIN_COUNT = 0xFF9A
def _bcm_to_dec(value):
return (value >> 4) * 10 + (value & 0x0F)
class GameWrapperSuperMarioLand(PyBoyGameWrapper):
"""
This class wraps Super Mario Land, and provides easy access to score, coins, lives left, time left, world and a
"fitness" score for AIs.
__Only world 1-1 is officially supported at the moment. Support for more worlds coming soon.__
If you call `print` on an instance of this object, it will show an overview of everything this object provides.
"""
cartridge_title = "SUPER MARIOLAN"
tiles_compressed = tiles_compressed
tiles_minimal = tiles_minimal
def __init__(self, *args, **kwargs):
self.shape = (20, 16)
"""The shape of the game area"""
self.world = (0, 0)
"GameWrapperKirbyDreamLand.post_tick": False,
}
from pyboy.utils import WindowEvent
from pyboy.logger import logger
from .base_plugin import PyBoyGameWrapper
try:
from cython import compiled
cythonmode = compiled
except ImportError:
cythonmode = False
class GameWrapperKirbyDreamLand(PyBoyGameWrapper):
"""
This class wraps Kirby Dream Land, and provides easy access to score and a "fitness" score for AIs.
If you call `print` on an instance of this object, it will show an overview of everything this object provides.
"""
cartridge_title = "KIRBY DREAM LA"
def __init__(self, *args, **kwargs):
self.shape = (20, 16)
"""The shape of the game area"""
self.score = 0
"""The score provided by the game"""
self.health = 0
"""The health provided by the game"""
self.lives_left = 0
"""The lives remaining provided by the game"""
def reset_game(self, timer_div=None):
"""
After calling `start_game`, use this method to reset Mario to the beginning of world 1-1.
If you want to reset to later parts of the game -- for example world 1-2 or 3-1 -- use the methods
`pyboy.PyBoy.save_state` and `pyboy.PyBoy.load_state`.
Kwargs:
timer_div (int): Replace timer's DIV register with this value. Use `None` to randomize.
"""
PyBoyGameWrapper.reset_game(self, timer_div=timer_div)
# Compressed assigns an ID to each Tetromino type
tiles_compressed = np.zeros(TILES, dtype=np.uint8)
# BLANK, J, Z, O, L, T, S, I, BLACK
tiles_types = [[47], [129], [130], [131], [132], [133], [134], [128, 136, 137, 138, 139, 143], [135]]
for tiles_type_ID, tiles_type in enumerate(tiles_types):
for tile_ID in tiles_type:
tiles_compressed[tile_ID] = tiles_type_ID
# Minimal has 3 id's: Background, Tetromino and "losing tile" (which fills the board when losing)
tiles_minimal = np.ones(TILES, dtype=np.uint8) # For minimal everything is 1
tiles_minimal[47] = 0 # Except BLANK which is 0
tiles_minimal[135] = 2 # And background losing tiles BLACK which is 2
class GameWrapperTetris(PyBoyGameWrapper):
"""
This class wraps Tetris, and provides easy access to score, lines, level and a "fitness" score for AIs.
If you call `print` on an instance of this object, it will show an overview of everything this object provides.
"""
cartridge_title = "TETRIS"
tiles_compressed = tiles_compressed
tiles_minimal = tiles_minimal
def __init__(self, *args, **kwargs):
self.shape = (10, 18)
"""The shape of the game area"""
self.score = 0
"""The score provided by the game"""
self.level = 0
"""The current level"""