def moveDownWithLandscapeEllTest(): printTestName() board = PlayingBoard() setCellsOfBoard(landscape1, board) piece = Ell(board) doMultipleMoves(piece, 4, 10, 0) verifyFalse("Ell down into landscape--partially obstructed, return value", piece.moveDown()) verifyBoardWithLandscape("Ell down into landscape--partially obstructed", [(10,7),(10,8),(10,9),(11,7)], board, landscape1) doMultipleMoves(piece, -4, 0, 1) doMultipleMoves(piece, -3, 1, 0) verifyFalse("Ell down into landscape--partially obstructed, return value", piece.moveDown()) verifyBoardWithLandscape("Ell down into landscape--partially obstructed", [(10,1),(11,1),(12,1),(10,0)], board, landscape1) # Restart board = PlayingBoard() setCellsOfBoard(landscape2, board) piece = Ell(board) doMultipleMoves(piece, 0, 3, 1) # Lower into open space and rotate doMultipleMoves(piece, 0, 12, 0) # Lower into "canyon" verifyFalse("Ell down into landscape--fully obstructed, return value", piece.moveDown()) verifyBoardWithLandscape("Ell down into landscape--fully obstructed", [(14, 4),(15, 4),(16, 4),(14,3)], board, landscape2) print
def moveDownWithLandscapeJayTest(): printTestName() board = PlayingBoard() setCellsOfBoard(landscape1, board) piece = Jay(board) doMultipleMoves(piece, -3, 10, 0) verifyFalse("Jay down into landscape--partially obstructed, return value", piece.moveDown()) verifyBoardWithLandscape("Jay down into landscape--partially obstructed", [(10, 0), (10, 1), (10, 2), (11, 2)], board, landscape1) # Split up so it doesn't get caught doMultipleMoves(piece, 3, 0, 0) doMultipleMoves(piece, 0, 0, 3) doMultipleMoves(piece, 4, 1, 0) verifyFalse("Jay down into landscape--partially obstructed, return value", piece.moveDown()) verifyBoardWithLandscape("Jay down into landscape--partially obstructed", [(10, 8), (11, 8), (12, 8), (10, 9)], board, landscape1) # Restart board = PlayingBoard() setCellsOfBoard(landscape1, board) piece = Jay(board) doMultipleMoves(piece, -2, 3, 3) # Lower into open space and rotate doMultipleMoves(piece, 0, 13, 0) # Lower into "canyon" verifyFalse("Jay down into landscape--fully obstructed, return value", piece.moveDown()) verifyBoardWithLandscape("Jay down into landscape--fully obstructed", [(15, 2), (16, 2), (17, 2), (15, 3)], board, landscape1) print
def moveDownWithLandscapeLeftZagTest(): printTestName() board = PlayingBoard() setCellsOfBoard(landscape1, board) piece = LeftZag(board) doMultipleMoves(piece, 5, 10, 1) verifyFalse("LeftZag down into landscape--obstructed by zag, return values", piece.moveDown()) verifyBoardWithLandscape("LeftZag down into landscape--obstructed by zag", [(9,9),(10,8),(10,9),(11,8)], board, landscape1) doMultipleMoves(piece, -3, 0, 0) # Move left, then down doMultipleMoves(piece, 0, 5, 0) verifyTrue("LeftZag down into landscape--barely clear, return value", piece.moveDown()) verifyBoardWithLandscape("LeftZag down into landscape--barely clear", [(15,6),(16,5),(16,6),(17,5)], board, landscape1) # Restart board = PlayingBoard() setCellsOfBoard(landscape2, board) piece = LeftZag(board) doMultipleMoves(piece, -3, 10, 0) # Lower into open space and rotate verifyFalse("LeftZag down into landscape--hung on tab, return value", piece.moveDown()) verifyBoardWithLandscape("LeftZag down into landscape--hung on tab", [(10,0),(10,1),(11,1),(11,2)], board, landscape2) doMultipleMoves(piece, 6, 0, 0) # Move left into open space piece.rotate() doMultipleMoves(piece, 0, 5, 0) # Lower into "canyon" verifyFalse("LeftZag down into landscape--fully obstructed, return value", piece.moveDown()) verifyBoardWithLandscape("LeftZag down into landscape--fully obstructed", [(14, 7),(15, 6),(15, 7),(16, 6)], board, landscape2) print
def moveDownEllTest(): printTestName() board = PlayingBoard() piece = Ell(board) verifyTrue("Ell initial moveDown return value", piece.moveDown()) verifyBoardSparse("Ell board after one moveDown", [(1, 3), (1, 4), (1, 5), (2, 3)], board) doMultipleMoves(piece, 0, 14, 0) verifyBoardSparse("Ell board after moving one space from bottom edge", [(15, 3), (15, 4), (15, 5), (16, 3)], board) verifyTrue("Ell next-to-last moveDown return value", piece.moveDown()) verifyBoardSparse("Ell board after trying to move down again", [(16, 3), (16, 4), (16, 5), (17, 3)], board) verifyFalse("Ell last moveDown return value", piece.moveDown()) verifyBoardSparse("Ell board after trying to move down again", [(16, 3), (16, 4), (16, 5), (17, 3)], board) print
def moveDownBarTest(): printTestName() board = PlayingBoard() piece = Bar(board) verifyTrue("Bar initial moveDown return value", piece.moveDown()) verifyBoardSparse("Bar board after one moveDown", [(1, 3), (1, 4), (1, 5), (1, 6)], board) doMultipleMoves(piece, 0, 15, 0) verifyBoardSparse("Bar board after moving one space from bottom edge", [(16, 3), (16, 4), (16, 5), (16, 6)], board) verifyTrue("Bar next-to-last moveDown return value", piece.moveDown()) verifyBoardSparse("Bar board after trying to move down again", [(17, 3), (17, 4), (17, 5), (17, 6)], board) verifyFalse("Bar last moveDown return value", piece.moveDown()) verifyBoardSparse("Bar board after trying to move down again", [(17, 3), (17, 4), (17, 5), (17, 6)], board) print
def rotateMrChunkyTest(): printTestName() board = PlayingBoard() piece = MrChunky(board) piece.rotate() verifyBoardSparse("MrChunky board after one rotation", [(0, 4), (0, 5), (1, 4), (1, 5)], board) print
def moveDownWithLandscapeBarTest(): printTestName() board = PlayingBoard() setCellsOfBoard(landscape1, board) piece = Bar(board) doMultipleMoves(piece, 3, 10, 0) verifyFalse("Bar down into landscape--partially obstructed, return value", piece.moveDown()) verifyBoardWithLandscape("Bar down into landscape--partially obstructed", [(10,6),(10,7),(10,8),(10,9)], board, landscape1) # Need new everything, since piece bottomed out above board = PlayingBoard() setCellsOfBoard(landscape1, board) piece = Bar(board) doMultipleMoves(piece, 0, 3, 3) # Lower into open space and rotate doMultipleMoves(piece, 0, 12, 0) # Lower into "canyon" verifyFalse("Bar down into landscape--fully obstructed, return value", piece.moveDown()) verifyBoardWithLandscape("Bar down into landscape--fully obstructed", [(13, 4),(14, 4),(15, 4),(16, 4)], board, landscape1) print
def dropEllTest(): printTestName() board = PlayingBoard() piece = Ell(board) rotateAndDropHelper(piece, board, 0, [(16,3),(16,4),(16,5),(17,3)]) board = PlayingBoard() piece = Ell(board) rotateAndDropHelper(piece, board, 1, [(15,4),(16,4),(17,4),(15,3)]) board = PlayingBoard() piece = Ell(board) rotateAndDropHelper(piece, board, 2, [(17,3),(17,4),(17,5),(16,5)]) board = PlayingBoard() piece = Ell(board) rotateAndDropHelper(piece, board, 3, [(15,4),(16,4),(17,4),(17,5)]) board = PlayingBoard() piece = Ell(board) rotateAndDropHelper(piece, board, 0, [(16,3),(16,4),(16,5),(17,3)]) print
def rotateWithLandscapeBarTest(): printTestName() board = PlayingBoard() setCellsOfBoard(landscape1, board) piece = Bar(board) doMultipleMoves(piece, -2, 11, 0) piece.rotate() verifyBoardWithLandscape("Bar rotate in landscape--barely clear", [(10,2),(11,2),(12,2),(13,2)], board, landscape1) piece.rotate() verifyBoardWithLandscape("Bar rotate in landscape--obstructed", [(10,2),(11,2),(12,2),(13,2)], board, landscape1) print
def dropBarTest(): printTestName() board = PlayingBoard() piece = Bar(board) rotateAndDropHelper(piece, board, 0, [(17,3),(17,4),(17,5),(17,6)]) board = PlayingBoard() piece = Bar(board) rotateAndDropHelper(piece, board, 1, [(14,4),(15,4),(16,4),(17,4)]) board = PlayingBoard() piece = Bar(board) rotateAndDropHelper(piece, board, 2, [(17,2),(17,3),(17,4),(17,5)]) board = PlayingBoard() piece = Bar(board) rotateAndDropHelper(piece, board, 3, [(14,4),(15,4),(16,4),(17,4)]) board = PlayingBoard() piece = Bar(board) rotateAndDropHelper(piece, board, 4, [(17,3),(17,4),(17,5),(17,6)]) print
def moveDownWithLandscapeTeeTest(): printTestName() board = PlayingBoard() setCellsOfBoard(landscape1, board) piece = Tee(board) doMultipleMoves(piece, -3, 10, 1) verifyFalse("Tee down into landscape--partially obstructed, return value", piece.moveDown()) verifyBoardWithLandscape("Tee down into landscape--partially obstructed", [(9, 1), (10, 1), (11, 1), (10, 0)], board, landscape1) doMultipleMoves(piece, 7, 0, 1) verifyFalse("Tee down into landscape--partially obstructed, return value", piece.moveDown()) verifyBoardWithLandscape("Tee down into landscape--partially obstructed", [(10, 7), (10, 8), (10, 9), (9, 8)], board, landscape1) # Restart board = PlayingBoard() setCellsOfBoard(landscape2, board) piece = Tee(board) doMultipleMoves(piece, 2, 10, 3) # Lower into open space and rotate doMultipleMoves(piece, 0, 5, 0) # Lower into "canyon" verifyFalse("Tee down into landscape--fully obstructed, return value", piece.moveDown()) verifyBoardWithLandscape("Tee down into landscape--fully obstructed", [(14, 6), (15, 6), (16, 6), (15, 7)], board, landscape2) doMultipleMoves(piece, -1, 0, 0) # Move left into open space doMultipleMoves(piece, 0, 0, 1) # Rotate doMultipleMoves(piece, 0, 1, 0) # Lower into "canyon" verifyFalse("Tee down into landscape--fully obstructed, return value", piece.moveDown()) verifyBoardWithLandscape("Tee down into landscape--fully obstructed", [(16, 4), (16, 5), (16, 6), (17, 5)], board, landscape2) print
def moveRightWithLandscapeBarTest(): printTestName() board = PlayingBoard() setCellsOfBoard(landscape1, board) piece = Bar(board) doMultipleMoves(piece, 4, 10, 1) piece.moveRight() verifyBoardWithLandscape("Bar right into landscape--partially obstructed", [(9,8),(10,8),(11,8),(12,8)], board, landscape1) doMultipleMoves(piece, 0, 2, 0) piece.moveRight() verifyBoardWithLandscape("Bar right into landscape--fully obstructed", [(11,8),(12,8),(13,8),(14,8)], board, landscape1) print
def moveLeftWithLandscapeBarTest(): printTestName() board = PlayingBoard() setCellsOfBoard(landscape1, board) piece = Bar(board) doMultipleMoves(piece, -2, 10, 1) piece.moveLeft() verifyBoardWithLandscape("Bar left into landscape--partially obstructed", [(9,1),(10,1),(11,1),(12,1)], board, landscape1) doMultipleMoves(piece, 0, 4, 0) piece.moveLeft() verifyBoardWithLandscape("Bar left into landscape--fully obstructed", [(13,1),(14,1),(15,1),(16,1)], board, landscape1) print
def moveRightLeftZagTest(): printTestName() board = PlayingBoard() piece = LeftZag(board) piece.moveRight() verifyBoardSparse("LeftZag board after one moveRight", [(0,4),(0,5),(1,5),(1,6)], board) doMultipleMoves(piece, 3, 0, 0) verifyBoardSparse("LeftZag board after moving to right edge", [(0,7),(0,8),(1,8),(1,9)], board) piece.moveRight() verifyBoardSparse("LeftZag board after trying to move right again", [(0,7),(0,8),(1,8),(1,9)], board) print
def dropMrChunkyTest(): printTestName() board = PlayingBoard() piece = MrChunky(board) piece.drop() verifyBoardSparse("MrChunky board after drop", [(16, 4), (16, 5), (17, 4), (17, 5)], board) piece.drop() verifyBoardSparse("MrChunky board after trying to drop again", [(16, 4), (16, 5), (17, 4), (17, 5)], board) print
def moveDownWithLandscapeMrChunkyTest(): printTestName() board = PlayingBoard() setCellsOfBoard(landscape1, board) piece = MrChunky(board) doMultipleMoves(piece, 0, 15, 0) verifyFalse( "MrChunky down into landscape--partially obstructed, return value", piece.moveDown()) verifyBoardWithLandscape( "MrChunky down into landscape--partially obstructed", [(15, 4), (15, 5), (16, 4), (16, 5)], board, landscape1) # Need new everything, since piece bottomed out above board = PlayingBoard() setCellsOfBoard(landscape1, board) piece = MrChunky(board) doMultipleMoves(piece, 3, 14, 0) # Lower into "canyon" verifyFalse("MrChunky down into landscape--fully obstructed, return value", piece.moveDown()) verifyBoardWithLandscape("MrChunky down into landscape--fully obstructed", [(14, 7), (14, 8), (15, 7), (15, 8)], board, landscape1) print
def moveRightWithLandscapeEllTest(): printTestName() board = PlayingBoard() setCellsOfBoard(landscape1, board) piece = Ell(board) doMultipleMoves(piece, 3, 10, 3) piece.moveRight() verifyBoardWithLandscape("Ell right into landscape--partially obstructed", [(9,7),(10,7),(11,7),(11,8)], board, landscape1) doMultipleMoves(piece, 1, 3, 2) piece.moveRight() verifyBoardWithLandscape("Ell right into landscape--fully obstructed", [(12,8),(13,8),(14,8),(12,7)], board, landscape1) print
def moveRightEllTest(): printTestName() board = PlayingBoard() piece = Ell(board) piece.moveRight() verifyBoardSparse("Ell board after one moveRight", [(0,4),(0,5),(0,6),(1,4)], board) doMultipleMoves(piece, 3, 0, 0) verifyBoardSparse("Ell board after moving to right edge", [(0,7),(0,8),(0,9),(1,7)], board) piece.moveRight() verifyBoardSparse("Ell board after trying to move right again", [(0,7),(0,8),(0,9),(1,7)], board) print
def moveLeftWithLandscapeEllTest(): printTestName() board = PlayingBoard() setCellsOfBoard(landscape1, board) piece = Ell(board) doMultipleMoves(piece, -2, 10, 0) piece.moveLeft() verifyBoardWithLandscape("Ell left into landscape--partially obstructed", [(10,1),(10,2),(10,3),(11,1)], board, landscape1) doMultipleMoves(piece, -1, 3, 3) piece.moveLeft() verifyBoardWithLandscape("Ell left into landscape--fully obstructed", [(12,1),(13,1),(14,1),(14,2)], board, landscape1) print
def moveRightWithLandscapeLeftZagTest(): printTestName() board = PlayingBoard() setCellsOfBoard(landscape1, board) piece = LeftZag(board) doMultipleMoves(piece, 4, 12, 1) piece.moveRight() verifyBoardWithLandscape("LeftZag right into landscape--obstructed by long edge", [(11,8),(12,7),(12,8),(13,7)], board, landscape1) doMultipleMoves(piece, -1, 0, 0) # Need to move left before down doMultipleMoves(piece, 0, 4, 0) piece.moveRight() verifyBoardWithLandscape("LeftZag right into landscape--obstructed by tab", [(14,7),(15,6),(15,7),(16,6)], board, landscape1) print
def rotateWithLandscapeEllTest(): printTestName() board = PlayingBoard() setCellsOfBoard(landscape1, board) piece = Ell(board) # Need to split into 2 separate moves, else it gets caught the landscape doMultipleMoves(piece, 2, 10, 1) doMultipleMoves(piece, 0, 5, 0) piece.rotate() verifyBoardWithLandscape("Ell rotate in landscape--Barely clear", [(15,5),(15,6),(15,7),(14,7)], board, landscape1) piece.rotate() verifyBoardWithLandscape("Ell rotate in landscape--obstructed", [(15,5),(15,6),(15,7),(14,7)], board, landscape1) print
def moveRightWithLandscapeMrChunkyTest(): printTestName() board = PlayingBoard() setCellsOfBoard(landscape1, board) piece = MrChunky(board) doMultipleMoves(piece, 3, 10, 0) piece.moveRight() verifyBoardWithLandscape( "MrChunky right into landscape--partially obstructed", [(10, 7), (10, 8), (11, 7), (11, 8)], board, landscape1) doMultipleMoves(piece, 0, 2, 0) piece.moveRight() verifyBoardWithLandscape("MrChunky right into landscape--fully obstructed", [(12, 7), (12, 8), (13, 7), (13, 8)], board, landscape1) print
def moveLeftWithLandscapeMrChunkyTest(): printTestName() board = PlayingBoard() setCellsOfBoard(landscape1, board) piece = MrChunky(board) doMultipleMoves(piece, -3, 10, 0) piece.moveLeft() verifyBoardWithLandscape( "MrChunky left into landscape--partially obstructed", [(10, 1), (10, 2), (11, 1), (11, 2)], board, landscape1) doMultipleMoves(piece, 0, 4, 0) piece.moveLeft() verifyBoardWithLandscape("MrChunky left into landscape--fully obstructed", [(14, 1), (14, 2), (15, 1), (15, 2)], board, landscape1) print
def moveLeftWithLandscapeLeftZagTest(): printTestName() board = PlayingBoard() setCellsOfBoard(landscape1, board) piece = LeftZag(board) doMultipleMoves(piece, -2, 11, 1) piece.moveLeft() verifyBoardWithLandscape("LeftZag left into landscape--obstructed by long edge", [(10,2),(11,1),(11,2),(12,1)], board, landscape1) doMultipleMoves(piece, 2, 0, 0) # Need to move right before down piece.rotate() # Need to rotate before down doMultipleMoves(piece, 0, 6, 0) piece.moveLeft() verifyBoardWithLandscape("LeftZag left into landscape--obstructed by zag", [(15,3),(15,4),(16,4),(16,5)], board, landscape1) print
def moveLeftEllTest(): printTestName() board = PlayingBoard() piece = Ell(board) verifyBoardSparse("Initial Ell board", [(0,3),(0,4),(0,5),(1,3)], board) piece.moveLeft() verifyBoardSparse("Ell board after one moveLeft", [(0,2),(0,3),(0,4),(1,2)], board) doMultipleMoves(piece, -2, 0, 0) verifyBoardSparse("Ell board after moving to left edge", [(0,0),(0,1),(0,2),(1,0)], board) piece.moveLeft() verifyBoardSparse("Ell board after trying to move left again", [(0,0),(0,1),(0,2),(1,0)], board) print
def rotateWithLandscapeLeftZagTest(): printTestName() board = PlayingBoard() setCellsOfBoard(landscape2, board) piece = LeftZag(board) # Need to split into 2 separate moves, else it gets caught the landscape doMultipleMoves(piece, 6, 11, 1) piece.rotate() verifyBoardWithLandscape("LeftZag rotate in landscape--obstructed", [(10,8),(11,7),(11,8),(12,7)], board, landscape2) piece.moveLeft() # gets some room to spin doMultipleMoves(piece, 1, 0, 2) piece.rotate() verifyBoardWithLandscape("LeftZag rotate in landscape--barely clear", [(11,6),(11,7),(12,7),(12,8)], board, landscape2) print
def moveRightMrChunkyTest(): printTestName() board = PlayingBoard() piece = MrChunky(board) piece.moveRight() verifyBoardSparse("MrChunky board after one moveRight", [(0, 5), (0, 6), (1, 5), (1, 6)], board) doMultipleMoves(piece, 4, 0, 0) verifyBoardSparse("MrChunky board after moving to right edge", [(0, 8), (0, 9), (1, 8), (1, 9)], board) piece.moveRight() verifyBoardSparse("MrChunky board after trying to move right again", [(0, 8), (0, 9), (1, 8), (1, 9)], board) print
def rotateWithLandscapeRightZigTest(): printTestName() board = PlayingBoard() setCellsOfBoard(landscape2, board) piece = RightZig(board) # Need to split into 2 separate moves, else it gets caught the landscape doMultipleMoves(piece, -3, 11, 3) piece.rotate() verifyBoardWithLandscape("RightZig rotate in landscape--obstructed", [(10, 1), (11, 1), (11, 2), (12, 2)], board, landscape2) doMultipleMoves(piece, 1, 0, 0) piece.rotate() verifyBoardWithLandscape("RightZig rotate in landscape--barely clear", [(11, 2), (11, 3), (12, 1), (12, 2)], board, landscape2) print
def rotateEllTest(): printTestName() board = PlayingBoard() piece = Ell(board) # Move piece below top edge to give space to rotate doMultipleMoves(piece, 0, 2, 0) piece.rotate() verifyBoardSparse("Ell board after one rotation", [(1,4),(2,4),(3,4),(1,3)], board) piece.rotate() verifyBoardSparse("Ell board after two rotations", [(2,3),(2,4),(2,5),(1,5)], board) piece.rotate() verifyBoardSparse("Ell board after three rotations", [(1,4),(2,4),(3,4),(3,5)], board) piece.rotate() verifyBoardSparse("Ell board after four rotations", [(2,3),(2,4),(2,5),(3,3)], board) print
def mrChunkyTests(): """Runs the tests.""" initialFailureCount = getCountOfFailedTests() printTestSetName() newPieceTest(MrChunky(PlayingBoard())) print moveLeftMrChunkyTest() moveRightMrChunkyTest() moveDownMrChunkyTest() dropMrChunkyTest() rotateMrChunkyTest() if getCountOfFailedTests() > initialFailureCount: announceAborting("MR CHUNKY") else: moveLeftWithLandscapeMrChunkyTest() moveRightWithLandscapeMrChunkyTest() moveDownWithLandscapeMrChunkyTest()