def insertGoalBlockInEmptyGrid(goalBlock, emptyGrid):
    emptyGrid = convertTupleToList(emptyGrid)
    
    for i in range(len(emptyGrid) - getSize(goalBlock)[0], len(emptyGrid)):
        for j in range (0, getSize(goalBlock)[1]):
            emptyGrid[i][j] = 1
            
    return convertListToTuple(emptyGrid)
Ejemplo n.º 2
0
def insertGoalBlockInEmptyGrid(goalBlock, emptyGrid):
    emptyGrid = convertTupleToList(emptyGrid)

    for i in range(len(emptyGrid) - getSize(goalBlock)[0], len(emptyGrid)):
        for j in range(0, getSize(goalBlock)[1]):
            emptyGrid[i][j] = 1

    return convertListToTuple(emptyGrid)
def insertGoalBlockInStartPosition(goalBlock, emptyGrid):
    emptyGrid = convertTupleToList(emptyGrid)
    
    goalSize = getSize(goalBlock)
    
    for i in range(0, goalSize[0]):
        for j in range (len(emptyGrid[i]) - goalSize[1], len(emptyGrid[i])):
            emptyGrid[i][j] = 1
            
    return convertListToTuple(emptyGrid)
Ejemplo n.º 4
0
def insertGoalBlockInStartPosition(goalBlock, emptyGrid):
    emptyGrid = convertTupleToList(emptyGrid)

    goalSize = getSize(goalBlock)

    for i in range(0, goalSize[0]):
        for j in range(len(emptyGrid[i]) - goalSize[1], len(emptyGrid[i])):
            emptyGrid[i][j] = 1

    return convertListToTuple(emptyGrid)
Ejemplo n.º 5
0
def exchangeBlock(grid, symbol1, symbol2):
    visitedPos = set()

    grid = convertTupleToList(grid)

    for i in range(len(grid)):
        for j in range(len(grid[i])):
            if grid[i][j] == symbol1:
                visitedPos.add((i, j))
                grid[i][j] = symbol2

    for i in range(len(grid)):
        for j in range(len(grid[i])):
            if grid[i][j] == symbol2 and (i, j) not in visitedPos:
                grid[i][j] = symbol1

    return convertListToTuple(grid)
def exchangeBlock(grid, symbol1, symbol2):
    visitedPos = set()
    
    grid = convertTupleToList(grid)
    
    for i in range(len(grid)):
        for j in range(len(grid[i])):
            if grid[i][j] == symbol1:
                visitedPos.add((i, j))
                grid[i][j] = symbol2
        
    for i in range(len(grid)):
        for j in range(len(grid[i])):
            if grid[i][j] == symbol2 and (i, j) not in visitedPos:
                grid[i][j] = symbol1

    return convertListToTuple(grid)
    
Ejemplo n.º 7
0
def insertNonGoalBlock(block, grid, symbol):
    (blockX, blockY) = getSize(block)
    # Get the position of the leftmost upper corner
    insertPos = getInsertPosition(block, grid)

    i = insertPos[0]
    j = insertPos[1]

    grid = convertTupleToList(grid)
    grid[i][j] = symbol

    # Fill it up
    for k in range(blockX):
        for l in range(blockY):
            if grid[i + k][j + l] == 0:
                grid[i + k][j + l] = symbol

    return convertListToTuple(grid)
def insertNonGoalBlock(block, grid, symbol):
    (blockX, blockY) = getSize(block)
    # Get the position of the leftmost upper corner
    insertPos = getInsertPosition(block, grid)
   
    i = insertPos[0]
    j = insertPos[1]
    
    grid = convertTupleToList(grid)
    grid[i][j] = symbol
    
    
    # Fill it up
    for k in range(blockX):
        for l in range(blockY):
            if grid[i + k][j + l] == 0:
                grid[i + k][j + l] = symbol

                
    return convertListToTuple(grid)
    for i in range(0, int(floor(len(grid)/2))):
        for j in range(int(floor(len(grid)/2)), len(grid)):
            if grid[i][j] == symbol:
                return True
        
    return False
   
    

#_______________________________EXTEND OPERATIONS (NOT USED GENERALLY)_____________________________________

def extendBottom(grid, (x,y), blockY, symbol):
    grid = convertTupleToList(grid)
    for j in range(y, y + blockY):
        grid[x + 1][j] = symbol
    return convertListToTuple(grid)

def extendLeft(grid, (x,y), blockX, symbol):
    grid = convertTupleToList(grid)
    for i in range(x - blockX + 1, x + 1):
        grid[i][y - 1] = symbol
    return convertListToTuple(grid)

def extendTop(grid, (x,y), blockX, blockY, symbol):
    grid = convertTupleToList(grid)
    for j in range(y, y + blockY):
        grid[x - blockX][j] = symbol
    return convertListToTuple(grid)

def extendRight(grid, (x,y), blockX, blockY, symbol):
    grid = convertTupleToList(grid)
Ejemplo n.º 10
0
    for i in range(0, int(floor(len(grid) / 2))):
        for j in range(int(floor(len(grid) / 2)), len(grid)):
            if grid[i][j] == symbol:
                return True

    return False


#_______________________________EXTEND OPERATIONS (NOT USED GENERALLY)_____________________________________


def extendBottom(grid, (x, y), blockY, symbol):
    grid = convertTupleToList(grid)
    for j in range(y, y + blockY):
        grid[x + 1][j] = symbol
    return convertListToTuple(grid)


def extendLeft(grid, (x, y), blockX, symbol):
    grid = convertTupleToList(grid)
    for i in range(x - blockX + 1, x + 1):
        grid[i][y - 1] = symbol
    return convertListToTuple(grid)


def extendTop(grid, (x, y), blockX, blockY, symbol):
    grid = convertTupleToList(grid)
    for j in range(y, y + blockY):
        grid[x - blockX][j] = symbol
    return convertListToTuple(grid)