def setUp(self): self.white_pawn = Pawn(color.white, Location(1, 0)) self.black_pawn = Pawn(color.black, Location(1, 0)) self.white_pawn_move = Move(Location(2, 0), piece=self.white_pawn, status=notation_const.MOVEMENT, start_loc=Location(1, 0)) self.start_specified = Move(Location(2, 0), piece=self.white_pawn, status=notation_const.MOVEMENT, start_loc=Location(3, 5))
def create_move(self, end_loc, status): # TODO: fix circular imports from Chess import Move return Move(end_loc=end_loc, piece=self, status=status, start_loc=self.location)
def testStr(self): self.assertEqual(str(self.start_specified), "f4a3") self.white_pawn_move = Move(Location(7, 0), piece=self.white_pawn, status=notation_const.MOVEMENT, start_loc=Location(6, 0), promoted_to_piece=Queen(color.white, Location(7, 0)))
def test_incomplete_alg_piece_movement_with_file_specified_alt(self): self.assertEqual( converter.incomplete_alg("Ngf3", color.white, self.test_board), Move( end_loc=Location.from_string("f3"), piece=Knight(color.white, Location.from_string("g1")), status=notation_const.MOVEMENT, start_loc=Location.from_string("g1") ) )
def test_incomplete_alg_pawn_movement(self): self.assertEqual( converter.incomplete_alg("e4", color.white, self.test_board), Move( end_loc=Location.from_string("e4"), piece=Pawn(color.white, Location.from_string("e4")), status=notation_const.MOVEMENT, start_loc=Location.from_string("e2") ) )
def test_incomplete_alg_piece_capture(self): self.test_board.update(converter.short_alg("Nf3", color.white, self.test_board)) self.test_board.update(converter.short_alg("e5", color.black, self.test_board)) self.assertEqual( converter.incomplete_alg("Nxe5", color.white, self.test_board), Move( end_loc=Location.from_string("e5"), piece=Knight(color.white, Location.from_string("f3")), status=notation_const.CAPTURE, start_loc=Location.from_string("f3") ) )
def test_incomplete_alg_pawn_promotion_with_capture(self): self.test_board.move_piece(Location.from_string("a2"), Location.from_string("a7")) self.assertEqual( converter.incomplete_alg("axb8=R", color.white, self.test_board), Move( end_loc=Location.from_string("b8"), piece=Pawn(color.white, Location.from_string("a7")), status=notation_const.CAPTURE_AND_PROMOTE, promoted_to_piece=Rook, start_loc=Location.from_string("a7") ) )
def test_incomplete_alg_pawn_promotion(self): self.test_board.move_piece(Location.from_string("a2"), Location.from_string("a7")) self.test_board.remove_piece_at_square(Location.from_string("a8")) self.assertEqual( converter.incomplete_alg("a8=Q", color.white, self.test_board), Move( end_loc=Location.from_string("a8"), piece=Pawn(color.white, Location.from_string("e7")), status=notation_const.PROMOTE, promoted_to_piece=Queen, start_loc=Location.from_string("a7") ) )
def test_kingside_castle(self): self.board.update(converter.short_alg("e4", color.white, self.board)) self.board.update(converter.short_alg("Nf3", color.white, self.board)) self.board.update(converter.short_alg("Be2", color.white, self.board)) castle_move = Move( end_loc=Location.from_string("g1"), piece=King(color.white, Location.from_string("g1")), status=notation_const.KING_SIDE_CASTLE, start_loc=Location.from_string("e1") ) self.assertEqual( list(self.board.get_king(color.white).add_castle(self.board))[0], castle_move)
def test_queenside_castle(self): self.board.remove_piece_at_square(Location.from_string("b1")) self.board.remove_piece_at_square(Location.from_string("c1")) self.board.remove_piece_at_square(Location.from_string("d1")) castle_move = Move( end_loc=Location.from_string("c1"), piece=King(color.white, Location.from_string("c1")), status=notation_const.QUEEN_SIDE_CASTLE, start_loc=Location.from_string("e1") ) self.assertEqual( list(self.board.get_king(color.white).add_castle(self.board))[0], castle_move)
def setUp(self): self.test_board = Board.init_default() self.e_four_move = Move(end_loc=Location.from_string("e4"), piece=Pawn(color.white, Location.from_string("e4")), status=notation_const.MOVEMENT, start_loc=Location.from_string("e2"))
def testEquals(self): self.assertEqual(self.white_pawn_move, Move(end_loc=Location(2, 0), piece=self.white_pawn, status=notation_const.MOVEMENT, start_loc=Location(1, 0)))