Section 1: Introduction

The ancient game of Chess is played by two players, where two identical sets of pieces battle each other. Each set consists of eights pawns, two rooks, two knights, two bishops, one queen, and one king. The initial configuration of the chess board or "chessboard" is composed of an 8x8 grid of 64 equal squares alternately light (the "white" squares) and dark (the "black" squares). The chessboard is placed between the players in such a way that the near corner square to the right of the player is white.

The aim of the game is to capture the opponent's king. Whichever side captures the king first, wins the game. It may also be possible to reach a draw or stalemate. See image.

Requirements

The aim of this assignment is to implement a chess program in Java with a full graphic environment based on the rules of the game which are described in section 2. Your implementation must allow two human players to play each other over a network using the networking abilities of the Java language. A computer player is a requirement of this assignment. The game must have a history of moves feature which will allow players to revert back (or undo moves in other words) to previous movements. Computer vs Human player mode does not have some kind of intelligent ability on behalf of the computer player. A simple algorithm will suffice as a testing feature and as a simplistic player to demonstrate the game works.

Section 2: Game Rules

Each player must move in turn, and is not allowed to pass or skip a move. White always moves first. In general, a piece may be moved to an empty position or to a position held by an opponent's piece, but there are restrictions that depend on the type of piece (see the rules below). If a piece can be moved to a position held by an opponent's piece, the opponent's piece is "captured" and removed from the board. Note that the knight is the only piece that may move over/through another piece. Here are the specific rules for the individual pieces:

  • Pawns: A pawn can move forward one square into an empty square. The exception is the first time a pawn is moved. In that case it may move forward two squares if both squares are empty. The pawn can also move forward one square diagonally if that square is held by an opponent's piece. In that case the opponent's piece is captured. If it happens that a pawn reaches the opposite end of the board, it is replaced with a queen (really, with any other piece except a king, but the queen is the most powerful piece, and hence we ignore the other possibilities). As a result there may be more then one (black or white) queen on the board.
  • Rooks: A rook can move any number of squares in a straight line along any column or row. It cannot move over/through other pieces. If the target square is occupied by an opponent''s piece, this piece is captured.
  • Knights: A knight moves two squares in a straight line along any column or row and then one square in the orthogonal direction (i.e. in an "L shape"). The knight is the only piece that can move over/through other pieces (i.e. it can jump over other pieces). If the target square is occupied by an opponent's piece, this piece is captured.
  • Bishops: A bishop can move any number of squares in a diagonal. It cannot move over/through other pieces. If the target square is occupied by an opponent's piece, this piece is captured.
  • Queen: The queen can move any number of squares in a straight line (horizontally, vertically, and diagonally). It cannot move over/through other pieces. If the target square is occupied by an opponent's piece, this piece is captured.
  • King: The king can move one square in any direction, as long as this square is empty or occupied by an opponent's piece. If the target square is occupied by an opponent's piece, this piece is captured. That's basically it. In real chess, there are two extra rules, called castling and pawn en passant but you should ignore them in this assignment. There is also an additional rule for the king, which states that the king cannot move into a square where he may be captured in the next move by the opponent. Ignore this rule as well.
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.