Game chess Online using C++, Lecture notes of Electronics engineering

This topic i write about how to build chess using C++

Typology: Lecture notes

2020/2021

Uploaded on 09/05/2023

seth-srunpheng
seth-srunpheng 🇰🇭

2 documents

1 / 70

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
A
សាកលវិទ្យាល័យភូមិន្ទភនំពេញ
ROYAL UNIVERSITY OF PHNOM PENH
ល្បែងអុក
Game Chess Online
របាយការណបញ្ប់ឆ្ ទ្យី២
នន្ពេបា៉ា តឺម៉ាង់វិស្វកមមទ្យូរគមនាគមន្៏ ន្ិងពេឡិចត្តូន្ិច
A Final Report
in Partial Fulfilment of the Requirement for the Second Year
in Telecommunication and Electronics Engineering
សាំង លីមឈុន (SAING LYMCHHUN), ខ ៀវ នខេន្ទន (Khiev Noren) ,ឈន ខោម (Chhorn Chhom)
សិដ្ឋ ស្ស នខេង (SETH SRUNPHENG ) , សុ ុម បញ្ញ វឌ្ឍនា (Sokhom Panha Vathana)
េន សុវណ្ណ ៉ា (Phorn Sovannara)
August 2023
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46

Partial preview of the text

Download Game chess Online using C++ and more Lecture notes Electronics engineering in PDF only on Docsity!

A

សាកលវិទ្យាល័យភូមិន្ទភនំពេញ ROYAL UNIVERSITY OF PHNOM PENH

Game Chess Online

A Final Report

in Partial Fulfilment of the Requirement for the Second Year

in Telecommunication and Electronics Engineering

សាំង លីមឈុន (SAING LYMCHHUN), ខ ៀវ នខេន្ទនរ (Khiev Noren) ,ឈន ខោម (Chhorn Chhom) សិដ្ឋ ស្ សុនខេង (SETH SRUNPHENG ) , សុ ុ ម បញ្ញាវឌ្ឍនា (Sokhom Panha Vathana) េន សុវណ្ណា រ៉ា (Phorn Sovannara) August 2023

B

សាកលវិទ្យាល័យភូមិន្ទភនំពេញ ROYAL UNIVERSITY OF PHNOM PENH

Game Chess Online

A Final Report

in Partial Fulfilment of the Requirement for the Second Year

in Telecommunication and Electronics Engineering

គណៈកម្មការវាយតម្ម្ៃ: នអ្កគ្រូ ឈ ឿម្ វន្ថា August 2023

II

Abstract

Chess which does play between two players on a board is an

intellectual and mental game, it has its own rules of play which

help to enhance and prove the mental and intellectual activities of

the player, and this game has a huge number of players around

the whole world they have strongly interested to have play it. This

document deals with the fully computer Chess Game, First, the

game computerizes for two players to play chess according to all

the valid rules of the chess on computer. Secondly, to make the

game more interesting which will make users directly play against

a computer, computer intellectual force is added.

III

Table of contents

Page មូលន័យសង្ខេប ......................................................................................................................... I ABSTRACT ............................................................................................................. II 1 Introduction ............................................................................................................ 1 2 Chess Game ......................................................................................................... 5 2.1 Chess Game...................................................................................................... 5 2.1.1 Rules in Chess Game ................................................................................. 10 3 Computerized Chess ......................................................................................... 19 3.1 A Brief History of Computer Chess ............................................................. 19 3.2 What we need for Computerized Chess ..................................................... 20 3.2.1 Board Representation ................................................................................. 20 3.2.2 Move Generation ......................................................................................... 22 4 Intelligent Chess Game ..................................................................................... 25 4.1 The Concept of Artificial Intelligence ........................................................... 25 4.2 Complexity Intelligent chess game............................................................... 28 4.3 What we need for an intelligent chess game ............................................. 32 4.3.1 Search Techniques ..................................................................................... 33

VI

1 Introduction

Chess is a game for two players, dubbed White and Black.

The goal is to capture your opponent’s king. In the game, this is

known as a checkmate. Chess is played on a board with 64

squares. Each player begins with 16 pieces, lined up in two rows.

The first row is occupied by pieces called pawns. The next row

contains a king, a queen, two rooks, two bishops, and two knights.

Chess is defined as a game of “perfect information”

because both players are aware of the entire state of the game

world at all times: just by looking at the board, you can see which

pieces are alive and where they are located. Checkers, Go, Go-

Moku, Backgammon, and Othello are other members of the

category, but stud poker is not (you don’t know what cards your

opponent is holding in his hands). Here to be able to change

chess games from physical form to figurative form fully realistic,

several things are needed to make chess games computerized

and intelligent.

  • Some way to represent a chess board in memory, so that it
  • Rules to determine how to generate legal moves, so that it can

play without cheating (and verify that its human opponent is not

trying to pull a fast one on it!)

  • A technique to choose the move to make amongst all legal

possibilities, so that it can choose a move instead of being forced

to pick one at random.

  • A way to compare moves and positions, so that it makes

intelligent choices.

  • Some sort of user interface. Figure 1: Building Block of Computer Chess

development and implementation of chess games respectively

while the last chapter is dedicated to future enhancement and the

summary of the entire document. C++ has been selected for the

implementation of this project.

2. Chess Game

2.1. Chess Game

Chess is an old game. It likely came to the Western world

from India in the 6th century A.D. It's a game, too, of royal origin:

a test of someone’s intelligence and acumen on the battlefield, yet

today it's everyone’s game. For one, chess doesn’t require

expensive equipment to play. The game has another virtue, which

any player can explain: chess is fun.

Figure 2: History of Chess

In the Western world today, chess ranks among the most

popular board games and is played seemingly everywhere, by

anyone: in urban parks, living rooms, schools, and well-publicized

formal competitions. Children can learn to play chess at an early

board can be viewed sui generis, and the next move can be

determined by inspection of the current arrangement of game

pieces. In computer science terms, chess is combinatorial, too:

each successive move generates a (typically large) combination

of possibilities. And, further, chess is a bounded branch problem

in terms of search: computer scientists view chess as a large set

of branching possibilities, bounded by poor moves on the “bottom”

and good moves on the “top”. The roundedness of chess lends

itself to shortcuts, or “pruning”, where additional possibilities can

be ignored once one determines that a particular path along a

branch is already poor, relative to another branch.

For all the games theory analysis, though, human players

see chess in terms of tactics and strategy: thought. The ability for

a human player to win at chess requires some degree of

intellectual skill. One must “see” what is happening and what the

opponent's moves signify in terms of a specific tactic, often part of

a long-term strategy for victory. Still, the game at root remains

entirely determined by the position of its game pieces, and the

rules telling each player how they may be moved next.

The object of chess the goal of chess is to checkmate the

opponent’s king. Checkmate is when you attack the king, and the

opponent cannot make a move which removes that attack. The

player who is mated loses the game.

The game is played on a squared board divided into 64

squares, alternating from light to dark. The board is always set up

so that each player has the light square on her right-hand side,

(Remember: light on the right). Figure 1 shows the chess board

with pieces. The Queen always stands on the square of her own

color. Thus, the light-colored Queen must stand on the light-

colored square. A good way of remembering this is the saying:

The Queen is a fashionable lady. She likes her dress to match

her shoes! figure 3 illustrates the Chess board with pieces.

Figure 3: Chess Board with pieces

2.1.1 Rules in Chess Game

Chess game has their own special rules, which cases to

make them more interesting in the world. Some of them are listed

below.

1. King The king can move horizontally, vertically, and

diagonally like the queen, but only one step at a time. The king

may never enter a square that is threatened by an opposing

piece. In other words, you cannot place the king on a square

when your opponent could capture the king next move. figure 5

illustrates King Moves.

Figure 5: King Moves

2. Rook The rook moves vertically or horizontally in a straight

line. The rook cannot jump over other pieces, all squares between

the rook’s current square and its destination must be empty.

figure 6 illustrates Rook Moves.

Figure 6: Rook Moves

3. Bishop The bishop moves diagonally in a straight line. Like

the rook, the bishop cannot jump over other pieces. figure 7

illustrates Bishop Moves.

Figure 7: Bishop Moves

4. Queen The queen combines the movement of a rook and

a bishop. This makes the queen the strongest piece on the board.