Group 1 Presentation Final

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 22

Game Playing

Group 1:
– Md. Amirul Islam @ 1710177101
– Pintu Hossain @ 1710377103
– Md. Mustafizur Rahman @ 1710477104

ICE,RU
Game Playing
 Game Playing is an important field in
artificial intelligence.
 Game Playing in Artificial Intelligence is
the field where we need:
 to provide the rules
 legal moves and
 the conditions of winning or losing the
game so that it can make an illusion of
intelligence to the user.
Page 2 Group 1 ICE,RU
General Requirements for playing
Game
 Obey the laws of the game
 Characters aware of the environment
 Path finding (A* algorithm)
 Decision making and
 Planning.

Page 3 Group 1 ICE,RU


How to Play a Game?
Consider all the legal moves you can
make.
Each move leads to a new board
configuration (position).
Evaluate each resulting position and
determine which is best
Make that move. and
Wait for your opponent to move and
repeat?
Page 4 Group 1 ICE, RU
Computer Games Types
 Strategy Games
 Real-Time Strategy (RTS)
 Turn-Based Strategy (TBS)
 Helicopter view
 Role-Playing Games (RPG)
 Single-Player
 Multi-Player
 Action Games
 First-Person Shooters (FPS)
 First-Person Sneakers
 Sports Games
 Simulations
 Adventure Games and
 Puzzle Games

Page 5 Group 1 ICE, RU


An Example (Partial)
Game Tree
for

Simple Chess AI

Page 6 Group 1 ICE, RU


Simple Chess AI
Let’s explore some basic concepts that
will help us to create a simple chess AI
Move-generation
Board evaluation
Minimax and
Alpha beta pruning.

Page 7 Group 1 ICE, RU


Chess Pieces

Pieces
on the
Board

White
Diagram
Pieces
Black
Diagram
Pieces

King Queen Bishop Knight Rook Pawn

Page 8 Group 1 ICE, RU


Setting Up a Chess Board
“White to the Right”
Put the White corner
to the right side

Switching this can make


A game invalid.

Page 9 Group 1 ICE, RU


Setting Up the Pieces
Queen On Her Color
• White Queen is on a
white square
• Black Queen is on a
shaded square

A lady wants her shoes


to match her dress.

Check this before you


start the game.

Page 10 Group 1 ICE, RU


Pieces in Alphabetical Order
Add the pieces in
Alphabetical Order,
going out from the
King & Queen.
• Bishops next to K & Q
• Knights next to
Bishops
• Rooks in the Corners

Switching a Bishop and


a Knight is a common
mistake in setting up the
board.
Page 11 Group 1 ICE, RU
Add the Pawns in Front
Now the board is
ready to play Chess !

Page 12 Group 1 ICE, RU


Step 1: Move generation and
board visualization

• The move generation library(chess.js,  


chessboard.js) basically implements all
the rules of chess.
• Based on this, we can calculate all legal
moves for a given board state.

Page 13 Group 1 ICE, RU


A visualization of the move generation function. The starting position is used as
input and the output is all the possible moves from that position.
Page 14 Group 1 ICE, RU
Step 2 : Position evaluation
• Now let’s try to understand
which side is stronger in a
certain position.
• The simplest way to achieve
this is to count the relative
strength of the pieces on the
board using the following
table:
Sample Calculation:
White score =900+50=950 for 1 king & 1
Rook
Black score: 900+90+30=1020 for 1 king, 1
Queen, 1 Knight

Page 15 Group 1 ICE, RU


Step 3: Search tree using Minimax

• Minimax algorithm is a Process that


selects the move which leads to the
“Best” game state after considering
possible future moves,

Page 16 Group 1 ICE, RU


Step 3: Search tree using Minimax
-50 is the Depth=0
maximum of Best Move!
the 2 values
below
-80 is the Depth=1
minimum of
-50 is the
the 5 values
minimum of
below
the 4 values
below
Depth=
2

A visualization of the minimax algorithm in an artificial position. The best


move for white is b2-c3, because we can guarantee that we can get to a
position where the evaluation is -50

Page 17 Group 1 ICE, RU


 With minimax in place, It’s algorithm is starting to
understand some basic tactics of chess:

Minimax with depth level 2. 


Page 18 Group 1 ICE, RU
Step 4: Alpha-beta pruning
The alpha-beta
algorithm also is
more efficient if
we happen to
≤-80
visit first those
paths that lead to
good moves.

The positions we do not need to explore if alpha-beta pruning is


used and the tree is visited in the described order.

Page 19 Group 1 ICE, RU


Finally, Improved evaluation and alpha-
beta pruning with search depth of 3

Page 20 Group 1 ICE, RU


Questions ?

Page 21 Group 1 ICE, RU


Thank You

Page 22 Group 1 ICE, RU

You might also like