GithubHelp home page GithubHelp logo

ecattez / shahmat Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 992 KB

A Chess implementation with the Domain Driven Design

Home Page: https://ecattez.github.io/shahmat/

License: GNU General Public License v3.0

Java 100.00%

shahmat's Introduction

Shahmat

A Chess implementation with the Domain Driven Design

The Game

The ultimate aim in the chess game is delivering a checkmate – trapping your opponent´s king. The term checkmate is an alteration of the Persian phrase "Shah Mat", meaning literally, "the King is ambushed".

Each side starts out with 16 pieces, consisting of 8 pawns, 2 rooks, 2 knights, 2 bishops, 1 queen and 1 king, all in the same color.

White always goes first.

Pawn moves

Pawns are both simple and complex in their movements.

The pawn piece has the fewest options of any chess piece on the board in where it can move and it can only move forward until it reaches the other side of the board. Here are a few things to know about how a pawn chess piece moves:

  • It can only directly forward one square;
  • It can move directly forward two squares on their first move only;
  • It can move diagonally forward when capturing an opponent's chess piece;
  • If there is another piece in front of it, the pawn is stuck, unless there is a piece ahead on the capturing diagonals;
  • Once it reaches the other side of the chess board, the player may promote the pawn in for any other chess piece if they choose, except another king.

Pawn moves

En passant

En passant (French: [ɑ̃ paˈsɑ̃], lit. in passing) is a move in chess. It is a special pawn capture that can only occur immediately after a pawn makes a move of two squares from its starting square, and it could have been captured by an enemy pawn had it advanced only one square. The opponent captures the just-moved pawn "as it passes" through the first square. The result is the same as if the pawn had advanced only one square and the enemy pawn had captured it normally.

En passant is a unique privilege of pawns, other pieces cannot capture en passant. It is the only capture in chess in which the capturing piece does not replace the captured piece on its square.

En passant

Promotion

Promotion in chess is a rule that requires a pawn that reaches its eighth rank to be replaced by the player's choice of a queen, knight, rook, or bishop of the same color.

The new piece replaces the pawn within the same move. The choice of new piece is not limited to pieces previously captured, thus promotion can result in a player owning, for example, two or more queens despite starting the game with one.

Pawn promotion, or the threat of it, often decides the result in an endgame. Since the queen is the most powerful piece, the vast majority of promotions are to a queen. Promotion to a queen is also called queening; promotion to any other piece is referred to as underpromotion.

Rook

The rooks are the most simple-moving chess pieces on the board. Their movements are only straight, moving forward, backward or side to side. At any point in the game, the piece can move in any direction that is straight ahead, behind or to the side. Here are a few things to know about how the Rook chess piece moves:

  • It can move forward, backward, left or right at any time;
  • It can move anywhere from 1 to 7 squares in any direction, so long as it is not obstructed by any other piece;
  • It can capture an opponent piece that obstruct its way.

Rook moves

Bishop

The bishop chess piece is stuck moving in diagonals. Each player starts out with two bishop pieces, each one residing on its own color of square. Between both pieces, you can cover the entire board, but one piece can only cover one half of the board, only the colors of squares it started the game on.

  • It can move in any direction diagonally, so long as it is not obstructed by another piece.
  • It cannot move past any piece that is obstructing its path.
  • It can take any other piece on the board that is within its bounds of movement.

Bishop moves

Queen

The queen chess piece is like a combination of the Rook and Bishop chess pieces.

  • It queen can move in any direction on a straight or diagonal path.
  • It cannot move past any piece that is obstructing its path.
  • It can be used to capture any of your opponent's pieces on the board.

Queen moves

Knight

The Knight chess piece moves in a very mysterious way. Unlike Rooks, Bishops or Queens, the Knight is limited in the number of squares it can move across.

In fact, the piece moves in a shape similar to the uppercase "L". Here are the specifics:

  • it can move forward, backward, left or right two squares and must then move one square in either perpendicular direction.
  • it can only move to one of up to eight positions on the board.
  • it can move to any position not already inhabited by another piece of the same color.
  • it can skip over any other pieces to reach its destination position.

Knight moves

King

King chess pieces are somewhat limited in their movement. They cannot go riding across the chess board as quickly as most other pieces and they are easier to contain than most chess pieces from an opponent's perspective. Here are a few rules to note:

  • The king piece can move one single square in any direction.
  • The king cannot move onto a square that is currently occupied by a piece from its own team.

King moves

References

http://www.chesscoachonline.com/chess-articles/chess-rules https://www.wholesalechess.com/pages/new-to-chess/pieces.html https://en.wikipedia.org/wiki/Algebraic_notation_(chess)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.