예제 #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
파일: pp4.py 프로젝트: VinceCoder/CSPython
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 []