def __init__(self, data_string='', column_givens=None, row_givens=None):
        Grid.__init__(self, data_string)

        # Determine givens from a solved board if possible.
        if (
            len(self.unknown_positions) == 0 and
            column_givens is None and
            row_givens is None
        ):
            column_givens = []
            for x in range(self.x_size):
                column = self.get_column(x)
                column_givens.append(find_ranges(column))
            row_givens = []
            for y in range(self.y_size):
                row = self.get_row(y)
                row_givens.append(find_ranges(row))

        # Otherwise, just initialize them to blank if not specified.
        if column_givens is None:
            column_givens = [() for _ in range(self.x_size)]
        if row_givens is None:
            row_givens = [() for _ in range(self.y_size)]

        if len(column_givens) != self.x_size:
            raise ValueError('Incorrect number of column givens.')
        if len(row_givens) != self.y_size:
            raise ValueError('Incorrect number of row givens.')

        self.column_givens = column_givens
        self.row_givens = row_givens
    def __init__(self, data_string=''):
        Grid.__init__(self, data_string)
        self.precalc_corner_adjacency()

        # Add given number information.
        self.given_positions = set()
        for pos in self.positions:
            if self[pos] in GIVENS:
                self.given_positions.add(pos)
예제 #3
0
파일: bgmap.py 프로젝트: IronBear/xadir
	def __init__(self, map, width, height, res):
		Grid.__init__(self, width, height, map)
		self.terrain, self.borders, self.overlay = res.terrain, res.borders, res.overlay
		self.images = {}
		self.cell_size = TILE_SIZE
		self.x = self.y = 0
		self.sprites = Grid(width, height)
		for x, y in self.keys():
			tiles = self.get_real_tile((x, y))
			rect = tiles[0].get_rect()
			rect.top = y*TILE_SIZE[1] - (rect.height - TILE_SIZE[1])
			rect.left = x*TILE_SIZE[0]
			self.sprites[x, y] = AnimatedTile(tiles, rect, layer = L_MAP(y), interval = FPS / TILE_FPS)
예제 #4
0
    def __init__(self, parent):
        Grid.__init__(self, parent)
        self.spinCtrl = None
        self.changeEvent('spinCtrl', self.__setSpinControl)
        self.bind("Cell Reset", self.onCellReset)
        self.bind("Cell Focus Change", self.onCellFocusChange)
        self.changeEvent('visible', self.__onVisibleChange)
        # [What] PCM061503-0115 [Music] UI: Music list region is too short when music file playback (16:9 screen ratio)
        # [Why] The timing of resetCells is not current.
        # [How] The Size change should be the fornt of cell reset.
        self.unbind("Size Change", self.resetCells)
        self.bind("Size Change", self.__onSizeChange)
        self.bind('Size Change', self.resetCells)
        self.bind("Cell Reset", self.__onSizeChange)

        self.singleCol = False
        self.singleRow = False
        self.autoEnabled = True
        self.quickFindMode = 'Text'        # 'Index'
예제 #5
0
    def __init__(self, parent):
        Grid.__init__(self, parent)
        self.spinCtrl = None
        self.changeEvent('spinCtrl', self.__setSpinControl)
        self.bind("Cell Reset", self.onCellReset)
        self.bind("Cell Focus Change", self.onCellFocusChange)
        self.changeEvent('visible', self.__onVisibleChange)
        # [What] PCM061503-0115 [Music] UI: Music list region is too short when music file playback (16:9 screen ratio)
        # [Why] The timing of resetCells is not current.
        # [How] The Size change should be the fornt of cell reset.
        self.unbind("Size Change", self.resetCells)
        self.bind("Size Change", self.__onSizeChange)
        self.bind('Size Change', self.resetCells)
        self.bind("Cell Reset", self.__onSizeChange)

        self.singleCol = False
        self.singleRow = False
        self.autoEnabled = True
        self.quickFindMode = 'Text'  # 'Index'
예제 #6
0
	def __init__( self, x, y, limit ):
		Grid.__init__( self, x, y, limit )
		self.pids = 1
		self.runs = 0
		self.build()
예제 #7
0
파일: matrix.py 프로젝트: hieugomeister/ASU
 def __init__(self, rows, columns, fillValue=0):
     Grid.__init__(self, rows, columns, fillValue)
 def __init__(self, rows, columns):
     Grid.__init__(self, rows, columns)
     self.distances = None
예제 #9
0
 def __init__(self, mask):
   self.mask = mask
   Grid.__init__(self, self.mask.rows, self.mask.columns)
 def __init__(self, data_string):
     Grid.__init__(self, data_string)
     self.precalc_given_adjacencies()
     self.precalc_junctions()
     self.precalc_junction_adjacencies()
예제 #11
0
 def __init__(self, x, y):
     Grid.__init__(self, x, y)
     self.initEndCells = 0
     self.build()
     self.backTrackMap = {}
예제 #12
0
 def __init__(self, rows, columns):
   self.under_cells = []
   Grid.__init__(self, rows, columns)
예제 #13
0
파일: solver.py 프로젝트: thomas-/gp13-jaa
	def __init__( self, x, y ):
		Grid.__init__( self, x, y )
		self.initEndCells = 0
		self.build()
		self.backTrackMap = {}
예제 #14
0
  def __init__(self, rows):
    assert rows % 2 == 0, 'argument must be an even number'

    self.equator = rows // 2
    Grid.__init__(self, rows, 1)