Lab Project Object Oriented Programming: National University of Computer and Emerging Sciences

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

National University of Computer and Emerging Sciences

Lab Project
for
Object Oriented Programming

Lab Instructor(s) Saqib Hayat


Section F
Semester Spring 2019

FAST School of Computing


Develop the chess game in C++ using Polymorphism

Deadline 26 April

The nature and objectives of the game of chess

1.1 The game of chess is played between two opponents who move their pieces alternately on a
square board called a ‘chessboard’. The player with the white pieces commences the game. A
player is said to ‘have the move’, when his opponent’s move has been ‘made’. (See Article 6.7)
1.2 The objective of each player is to place the opponent’s king ‘under attack’ in such a way that the
opponent has no legal move. The player who achieves this goal is said to have ‘checkmated’ the
opponent’s king and to have won the game. Leaving one’s own king under attack, exposing one’s
own king to attack and also ’capturing’ the opponent’s king are not allowed. The opponent whose
king has been checkmated has lost the game.
1.3 If the position is such that neither player can possibly checkmate, the game is drawn.

The initial position of the pieces on the chessboard

2.1 The chessboard is composed of an 8 x 8 grid of 64 equal squares alternately light (the ‘white’
squares) and dark (the ‘black’ squares).
The chessboard is placed between the players in such a way that the near corner square to the
right of the player is white.
2.2 At the beginning of the game one player has 16 light-coloured pieces (the ‘white’ pieces); the
other has 16 dark-coloured pieces (the ‘black’ pieces).
These pieces are as follows:

A white king, usually indicated by the symbol

A white queen, usually indicated by the symbol

Two white rooks, usually indicated by the symbol

Two white bishops, usually indicated by the symbol

Two white knights, usually indicated by the symbol

Eight white pawns, usually indicated by the symbol

A black king, usually indicated by the symbol

A black queen, usually indicated by the symbol


Two black rooks, usually indicated by the symbol

Two black bishops, usually indicated by the symbol

Two black knights, usually indicated by the symbol

Eight black pawns, usually indicated by the symbol

2.3 The initial position of the pieces on the chessboard is as follows:

2.4 The eight vertical columns of squares are called ‘files’. The eight horizontal rows of squares are
called ‘ranks’. A straight line of squares of the same colour, running from one edge of the board to
an adjacent edge, is called a ‘diagonal’.

The moves of the pieces

3.1 It is not permitted to move a piece to a square occupied by a piece of the same colour. If a
piece moves to a square occupied by an opponent’s piece the latter is captured and removed
from the chessboard as part of the same move. A piece is said to attack an opponent’s piece if
the piece could make a capture on that square according to the Articles 3.2 to 3.8.
A piece is considered to attack a square, even if such a piece is constrained from moving to
that square because it would then leave or place the king of its own colour under attack.

3.2 The bishop may move to any square along a diagonal on which it stands.
3.3 The rook may move to any square along the file or the rank on which it stands.

3.4 The queen may move to any square along the file, the rank or a diagonal on which it stands.

3.5 When making these moves the bishop, rook or queen may not move over any intervening
pieces.

3.6 The knight may move to one of the squares nearest to that on which it stands but not on the
same rank, file or diagonal.
3.7 a. The pawn may move forward to the unoccupied square immediately in front of it on
the same file, or
b. on its first move the pawn may move as in 3.7.a or alternatively it may advance two
squares along the same file provided both squares are unoccupied, or
c. the pawn may move to a square occupied by an opponent’s piece, which is diagonally
in front of it on an adjacent file, capturing that piece.

d. A pawn attacking a square crossed by an opponent’s pawn which has advanced two
squares in one move from its original square may capture this opponent’s pawn as
though the latter had been moved only one square. This capture is only legal on the
move following this advance and is called an ‘en passant’ capture.

e. When a pawn reaches the rank furthest from its starting position it must be exchanged
as part of the same move on the same square for a new queen, rook, bishop or knight
of the same colour. The player’s choice is not restricted to pieces that have been
captured previously. This exchange of a pawn for another piece is called ‘promotion’
and the effect of the new piece is immediate.

3.8 a. There are two different ways of moving the king:


by moving to any adjoining square not attacked by one or more of the opponent’s pieces

or by ‘castling’. This is a move of the king and either rook of the same colour along the player’s
first rank, counting as a single move of the king and executed as follows: the king is
transferred from its original square two squares towards the rook on its original square, then
that rook is transferred to the square the king has just crossed.

b. (1) The right to castle has been lost:


a. if the king has already moved, or
b. with a rook that has already moved.

(2) Castling is prevented temporarily:

c. if the square on which the king stands, or the square which it must cross, or
the square which it is to occupy, is attacked by one or more of the opponent's pieces,
or
d. if there is any piece between the king and the rook with which castling is to be
effected.

3.9 The king is said to be 'in check' if it is attacked by one or more of the opponent's pieces, even
if such pieces are constrained from moving to that square because they would then leave or
place their own king in check. No piece can be moved that will either expose the king of the
same colour to check or leave that king in check.

For more detail visit


https://www.fide.com/component/handbook/?id=124&view=article

https://www.chess.com/learn-how-to-play-chess

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy