0% found this document useful (0 votes)
77 views5 pages

Chess Is A Two

Chess is a two-player strategy board game that originated in India in the 6th century. It is played on an 8x8 grid with 64 squares using 16 pieces per player including kings, queens, rooks, knights, bishops and pawns. The objective is to checkmate the opponent's king by putting it in a position where it cannot escape capture. Players take turns moving pieces according to each piece's rules with the goal of outmaneuvering the opponent. Chess requires strategic thinking and planning, making it a popular enduring game.

Uploaded by

Haroon Ijaz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
77 views5 pages

Chess Is A Two

Chess is a two-player strategy board game that originated in India in the 6th century. It is played on an 8x8 grid with 64 squares using 16 pieces per player including kings, queens, rooks, knights, bishops and pawns. The objective is to checkmate the opponent's king by putting it in a position where it cannot escape capture. Players take turns moving pieces according to each piece's rules with the goal of outmaneuvering the opponent. Chess requires strategic thinking and planning, making it a popular enduring game.

Uploaded by

Haroon Ijaz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Chess Game

Chess is a two-player strategy board game that is believed to have originated in India during the
Gupta Empire, around the 6th century. It's played on an 8x8 grid known as a chessboard with 64
squares of alternating colors. Each player controls 16 pieces, including a king, a queen, two
rooks, two knights, two bishops, and eight pawns.

The objective of the game is to checkmate the opponent's king, which means putting the king in a
position where it cannot escape capture. Players take turns moving their pieces across the board
following specific rules for each type of piece. Chess requires strategic thinking, planning, and
foresight, making it one of the most popular and enduring board games in the world.

Rules and Regulation’s:


In a chess game, each player controls 16 pieces of two different colors, typically white and black.
Here are the roles and the number of pieces for each side:

White Side:
1. King - 1 piece
2. Queen - 1 piece
3. Rooks - 2 pieces
4. Knights - 2 pieces
5. Bishops - 2 pieces
6. Pawns - 8 pieces
Black Side:
1. King - 1 piece
2. Queen - 1 piece
3. Rooks - 2 pieces
4. Knights - 2 pieces
5. Bishops - 2 pieces
6. Pawns - 8 pieces
The players take turns moving their pieces according to specific rules, and the ultimate goal is to
checkmate the opponent's king while safeguarding their own. Each piece has unique movement
capabilities, and players use them strategically to control the board and outmaneuver their
opponent.
In chess, there are various conditions and rules that players must follow during the game.
Some of the key conditions include:
1. Turn-Based Play: Players take turns to move their pieces. White always moves first, and
then players alternate turns.
2. Legal Moves: Each piece has specific rules governing its movement. Players must make
legal moves that adhere to the allowed patterns for each piece.
3. Capturing: When a player moves a piece to a square occupied by an opponent's piece, the
opponent's piece is captured and removed from the board.
4. Check: When a player's king is under threat of capture, it is said to be in "check." The
player must move their king out of check or protect it with another move; otherwise, they lose
the game.
5. Checkmate: If a player's king is in check, and there is no legal move they can make to
escape check, it is called "checkmate," and the game ends with that player's defeat.
6. Stalemate: If a player has no legal moves, and their king is not in check, it is a
"stalemate." The game ends in a draw, and no one wins.
7. En Passant: A special pawn capture rule that occurs when a pawn advances two squares
from its starting position, and an opponent's pawn could have captured it had it moved only one
square.
8. Castling: A special move that involves the king and one rook, designed to improve the
king's safety.

Code Chess game:


class ChessGame: # Place white pieces board[0] = ['R', 'N', 'B', 'Q', 'K', 'B',
'N',
'R']
def _init_(self): board[1] = ['P'] * 8 self.board = self.create_board()
# Place black pieces
self.current_player = "White" board[7] = ['r', 'n', 'b', 'q', 'k', 'b', 'n', 'r']
board[6] = ['p'] * 8
def create_board(self): return board board = []
for _ in range(8):
def print_board(self):
board.append([' '] * 8)
for row in self.board: end = tuple(map(int,
print(' '.join(row)) input("Enter end position
(row, col): ").split(',')))
self.make_move(start, end)
def is_valid_move(self, start, end):
# Implement validation rules here
return True
game = ChessGame()
game.play()
def make_move(self, start, end):
if self.is_valid_move(start, end): OUT PUT:
start_row, start_col = start
end_row, end_col = end
self.board[end_row][end_col] =
self.board[start_row][start_col]
self.board[start_row][start_col] = ' '
self.current_player = "Black" if
self.current_player == "White" else "White"
else:
print("Invalid move!")

def play(self): while True:

self.print_board()

print(f"{self.current_player}'s turn.")

start = tuple(

map(int, input("Enter start

position (row, col):

").split(',')))

Optimum moves by using Min Max algorithm and Alpha-Beta Pruning


Various algorithms have been developed to make optimum moves in chess. One of the most
well-known and widely used algorithms is the Minimax algorithm with Alpha-Beta Pruning.
The Minimax algorithm is a decision-making algorithm used in two-player games with perfect
information, like chess. It aims to find the best move for a player by exploring the game tree,
which represents all possible moves and their resulting positions.
The basic idea of the Minimax algorithm is to maximize the player's gain while assuming the
opponent will minimize it. It recursively evaluates the possible moves, assigning a score to each
position, and then chooses the move that leads to the best outcome for the player, assuming the
opponent plays optimally.
Alpha-Beta Pruning is an optimization technique used with the Minimax algorithm to reduce the
number of positions that need to be evaluated. It prunes branches of the game tree that are
unlikely to lead to a better outcome than previously found moves, significantly reducing the
search space and improving the efficiency of the algorithm.
Modern chess engines and AI programs use a combination of Minimax with Alpha-Beta Pruning
and other enhancements, such as transposition tables, iterative deepening, and evaluation
functions, to make optimal moves and compete at a high level against human players.

Difficulties face during chess development


First of all I do not know about the chess game. When task is assigned I search out on google
about the chess and got a basic information about the game but google does not explained the
game fully. Then I go on youtube for the lectures to understand the chess game. After hearing
few lectures I got little bit understanding of the game. In the last step I go on CHATGPT search
out different terms about chess also takes module of codes in python . CHATGPT fully
explained the game and also describes the roles and regulations of game and all conditions in the
game . The main difficulty I have faced is “how to search out things according to your topic” and
secondly understanding of the topic “What I have to do”. And I also face difficulty when I try to
make chess game moves optimum because I can not understand the concept of Alpha-Beta
Pruning properly.

Learning after developing games


I have learn many things during this whole journey first thing that I learn how to search topic
content on the online platforms , how to understand problem domains and methods to put your
efforts in the right way to achieve goals. Before this development I does not know the chess
game and how to play it. And I learn the importance of Python in the artificial intelligence and in
the game development world .And importance of algorithms in making games moves optimum
and to speed up our task using different algorithms.

You might also like