示例#1
0
def nextFreeSlot(defaultShape,boardHeight,boardLength,boardContents):
    for i in xrange(1,boardHeight*boardLength+1):
        if boardContents[i-1] != 1:
            shiftedLoc = pp2.pieceFits(boardLength,boardHeight,boardContents,defaultShape,i)
            if len(shiftedLoc):
                return shiftedLoc
    return []
示例#2
0
def nextFreeSlot(defaultShape,boardHeight,boardLength,boardContents):
    """
    Given a shape, board sizes, and the board's contents, the function
    checks whether a piece can fit in the next free slot. If not it returns
    a blank list [].
    """
    for i in range(1,boardHeight*boardLength+1):
        if boardContents[i-1] != 1:
            shiftedLoc = pp2.pieceFits(boardLength,boardHeight,boardContents,defaultShape,i)
            if len(shiftedLoc):
                return shiftedLoc
            else:
                return []
    return []