Programming a Chess Game in C# | Part 14 - En Passant

Опубликовано: 16 Апрель 2026
на канале: OttoBotCode
3,146
81

Learn how to program a Chess game in C#!

Welcome to part 14 of my C# Chess tutorial.
This time we give pawns the ability to capture en passant.
First, we add two positions to the Board class.
When a pawn advances two squares, we store the position of the skipped square in the board.
This is acheived using a class dedicated to this move, which we call "DoubleMove".
For actually capturing en passant, we add another move class called "EnPassant".
We generate both of these moves from the Pawn class.
Finally, we make sure that skipped squares are reset so they are never "out of date".

Assets:
https://ottobotcode.com/chess/ChessAs...

Source code is available here:
  / 78701  

Chapters:
0:00 - Plan
0:09 - Capturing En Passant
1:02 - Store Skipped Position
3:19 - DoublePawn Move
6:12 - EnPassant Move
8:56 - Generate New Moves
10:19 - An Issue!
11:15 - Reset Skipped Position
12:24 - Success!