示例#1
0
文件: console.py 项目: Thermionix/Ice
    def __init__(self, name, options={}):
        self.fullname = name
        self.shortname = utils.idx(options, 'nickname', name)
        self.extensions = utils.idx(options, 'extensions', "")
        self.custom_roms_directory = utils.idx(options, 'roms directory', None)
        self.prefix = utils.idx(options, 'prefix', "")
        self.icon = os.path.expanduser(utils.idx(options, 'icon', ""))
        self.images_directory = os.path.expanduser(utils.idx(options, 'images directory', ""))

        self.emulator = Emulator.lookup(utils.idx(options, 'emulator', ""))
示例#2
0
文件: console.py 项目: jzerbe/Ice
    def __init__(self, name, options={}):
        self.fullname = name
        self.shortname = utils.idx(options, 'nickname', name)
        self.extensions = utils.idx(options, 'extensions', "")
        self.custom_roms_directory = utils.idx(options, 'roms directory', None)
        self.prefix = utils.idx(options, 'prefix', "")
        self.icon = os.path.expanduser(utils.idx(options, 'icon', ""))
        self.images_directory = os.path.expanduser(utils.idx(options, 'images directory', ""))

        self.emulator = Emulator.lookup(utils.idx(options, 'emulator', ""))
示例#3
0
    def __init__(self, name, options={}):
        self.fullname = name
        self.shortname = utils.idx(options, "nickname", name)
        self.extensions = utils.idx(options, "extensions", "")
        self.custom_roms_directory = utils.idx(options, "roms directory", None)
        self.prefix = utils.idx(options, "prefix", "")
        self.icon = os.path.expanduser(utils.idx(options, "icon", ""))
        self.images_directory = os.path.expanduser(utils.idx(options, "images directory", ""))

        self.emulator = Emulator.lookup(utils.idx(options, "emulator", ""))
示例#4
0
def settings_emulators():
    emulators = []
    emulators_dict = settings.emulators()
    for name in emulators_dict.keys():
        emulator_data = emulators_dict[name]
        location = utils.idx(emulator_data, 'location', "")
        current_emulator = Emulator(name, location, emulator_data)
        if current_emulator.is_enabled(verbose=True):
            emulators.append(current_emulator)
    # After all of the invalid emulators have been removed, let the user know
    # which emulators have initialized successfully
    for emulator in emulators:
        ice_logger.log("Detected Emulator: %s" % emulator.name)
    return emulators
示例#5
0
def settings_emulators():
    emulators = []
    emulators_dict = settings.emulators()
    for name in emulators_dict.keys():
        emulator_data = emulators_dict[name]
        location = utils.idx(emulator_data, 'location', "")
        current_emulator = Emulator(name, location, emulator_data)
        if current_emulator.is_enabled(verbose=True):
            emulators.append(current_emulator)
    # After all of the invalid emulators have been removed, let the user know
    # which emulators have initialized successfully
    for emulator in emulators:
        ice_logger.log("Detected Emulator: %s" % emulator.name)
    return emulators
示例#6
0
 def __init__(self, name, location, options={}):
     self.name = name
     self.location = os.path.expanduser(location)
     self.format = utils.idx(options, 'command', "%l %r")
     filesystem_helper.assert_file_exists(self.location, self.__config_error_for_missing_emulator__())
示例#7
0
文件: yajilin.py 项目: kcaze/claspy
    def _solve(self):
        horizontalFences = [[] for i in range(self.rows)]
        verticalFences = [[] for i in range(self.cols)]
        for y in range(self.rows):
            for x in range(self.cols - 1):
                cellLeft = self.board.getCell(x, y)
                cellRight = self.board.getCell(x + 1, y)
                horizontalFences[y].append(BoolVar(
                ) if cellLeft == None and cellRight == None else False)
        for x in range(self.cols):
            for y in range(self.rows - 1):
                cellUp = self.board.getCell(x, y)
                cellDown = self.board.getCell(x, y + 1)
                verticalFences[x].append(BoolVar(
                ) if cellUp == None and cellDown == None else False)

        utils.require_single_closed_loop_v2(horizontalFences, verticalFences)
        shaded = [[
            BoolVar() if self.board.getCell(x, y) == None else False
            for x in range(self.cols)
        ] for y in range(self.rows)]
        # Shaded squares are those without loops or clues
        for y in range(self.rows):
            for x in range(self.cols):
                if self.board.getCell(x, y) == None:
                    require(shaded[y][x] == ~(\
                      utils.idx(horizontalFences,y,x-1,False) |\
                      utils.idx(horizontalFences,y,x,False) |\
                      utils.idx(verticalFences,x,y-1,False) |\
                      utils.idx(verticalFences,x,y,False)))
        # Shaded squares do not touch.
        for y in range(self.rows - 1):
            for x in range(self.cols):
                require(~(shaded[y][x] & shaded[y + 1][x]))
        for y in range(self.rows):
            for x in range(self.cols - 1):
                require(~(shaded[y][x] & shaded[y][x + 1]))
        # Require clue sums
        for y in range(self.rows):
            for x in range(self.cols):
                cell = self.board.getCell(x, y)
                if cell == None:
                    continue
                direction = cell[0]
                count = cell[1]
                if direction == U:
                    require(sum_bools(count, [shaded[i][x] for i in range(y)]))
                elif direction == D:
                    require(
                        sum_bools(
                            count,
                            [shaded[i][x] for i in range(y + 1, self.rows)]))
                elif direction == L:
                    require(sum_bools(count, [shaded[y][i] for i in range(x)]))
                elif direction == R:
                    require(
                        sum_bools(
                            count,
                            [shaded[y][i] for i in range(x + 1, self.cols)]))

        num_solutions = solve(quiet=True)
        solution = {
            'horizontalFences':
            [[1 if str(x) == '1' else 0 for x in r] for r in horizontalFences],
            'verticalFences':
            [[1 if str(x) == '1' else 0 for x in r] for r in verticalFences],
        }
        return (num_solutions, solution)
示例#8
0
 def __init__(self, name, location, options={}):
     self.name = name
     self.location = os.path.expanduser(location)
     self.format = utils.idx(options, 'command', "%l %r")
     filesystem_helper.assert_file_exists(
         self.location, self.__config_error_for_missing_emulator__())