def _allLegalMoves(self, board, color, actualEnums): mvs = [] for rNF in range(_Board.BOARD_LAYOUT_SIZE): for fNF in range(_Board.BOARD_LAYOUT_SIZE): fromPosn = _Posn(rNF, fNF) piece = board[fromPosn] if (piece is not None and piece.color == color): for rNT in range(_Board.BOARD_LAYOUT_SIZE): for fNT in range(_Board.BOARD_LAYOUT_SIZE): toPosn = _Posn(rNT, fNT) if board.isLegalMove(color, fromPosn, toPosn): mvs.append((fromPosn, toPosn)) self._assertListsEq(mvs, actualEnums)
def test_bWD4_correctValues(self): self._assertListsEq([(_Posn(6, 0), _Posn(5, 0)), (_Posn(6, 0), _Posn(4, 0)), (_Posn(6, 1), _Posn(5, 1)), (_Posn(6, 1), _Posn(4, 1)), (_Posn(6, 2), _Posn(5, 2)), (_Posn(6, 2), _Posn(4, 2)), (_Posn(6, 3), _Posn(5, 3)), (_Posn(6, 3), _Posn(4, 3)), (_Posn(6, 4), _Posn(5, 4)), (_Posn(6, 4), _Posn(4, 4)), (_Posn(6, 5), _Posn(5, 5)), (_Posn(6, 5), _Posn(4, 5)), (_Posn(6, 6), _Posn(5, 6)), (_Posn(6, 6), _Posn(4, 6)), (_Posn(6, 7), _Posn(5, 7)), (_Posn(6, 7), _Posn(4, 7)), (_Posn(7, 1), _Posn(5, 0)), (_Posn(7, 1), _Posn(5, 2)), (_Posn(7, 6), _Posn(5, 5)), (_Posn(7, 6), _Posn(5, 7))], enumMoves(getBoardWD4(), _b))
def test_newB_correctValues(self): # "Should be 20 possible moves at start") self._assertListsEq([(_Posn(0, 1), _Posn(2, 0)), (_Posn(0, 1), _Posn(2, 2)), (_Posn(0, 6), _Posn(2, 5)), (_Posn(0, 6), _Posn(2, 7)), (_Posn(1, 0), _Posn(2, 0)), (_Posn(1, 0), _Posn(3, 0)), (_Posn(1, 1), _Posn(2, 1)), (_Posn(1, 1), _Posn(3, 1)), (_Posn(1, 2), _Posn(2, 2)), (_Posn(1, 2), _Posn(3, 2)), (_Posn(1, 3), _Posn(2, 3)), (_Posn(1, 3), _Posn(3, 3)), (_Posn(1, 4), _Posn(2, 4)), (_Posn(1, 4), _Posn(3, 4)), (_Posn(1, 5), _Posn(2, 5)), (_Posn(1, 5), _Posn(3, 5)), (_Posn(1, 6), _Posn(2, 6)), (_Posn(1, 6), _Posn(3, 6)), (_Posn(1, 7), _Posn(2, 7)), (_Posn(1, 7), _Posn(3, 7))], enumMoves(getBoardNew(), _w))
def test_b5_LegalWhiteBishopMove(self): self.assertTrue(getBoard5().isLegalMove(_b, _Posn(3, 3), _Posn(2, 3)))
def test_b4_LegalWhiteBishopMove(self): self.assertTrue(getBoard4().isLegalMove(_w, _Posn(4, 5), _Posn(6, 3)))
def test_b3_LegalBlackPawnMove(self): self.assertTrue(getBoard3().isLegalMove(_b, _Posn(4, 2), _Posn(3, 2)))
def test_b2_LegalBlackQueenMove(self): self.assertTrue(getBoard2().isLegalMove(_b, _Posn(4, 2), _Posn(2, 2)))
def test_b1_LegalWhiteKingMove(self): self.assertTrue(getBoard1().isLegalMove(_w, _Posn(1, 3), _Posn(2, 3)))