Skip to content

Chess game with one or two players. In either mode, only valid moves can be performed. In one-player mode, minimax alpha-beta pruning is used to determine the computer's moves.

License

Notifications You must be signed in to change notification settings

bkthomps/Ajedrez

Repository files navigation

GitHubBuild License

Ajedrez

Chess game with one or two players. In either mode, only valid moves can be performed. In one-player mode, minimax alpha-beta pruning is used to determine the computer's moves.

Gameplay of user playing as white against the computer

Building

Java 17 or above is required. Run make to build and run the program.

Moves

There are six pieces:

  1. Pawn - can only move forward one square if nothing blocks it unless it has not yet been moved in which it may be moved two squares, captures diagonally or with en-passant as described below
  2. Knight - moves in an L pattern, meaning 2 squares vertically and 1 square horizontally or vice-versa, captures the piece it lands on
  3. Bishop - moves any number of squares diagonally, captures the pieces it lands on
  4. Rook - moves any number of squares in a straight line, captures the pieces it lands on
  5. Queen - moves any number of squares diagonally or in a straight line, captures the pieces it lands on
  6. King - moves one square diagonally or in a straight line, captures the pieces it lands on

For any move, it can only be performed if the player's king does not end up in check.

Special Moves:

  1. Pawn promotion - if the pawn reaches the end of the board, it must become a knight, bishop, rook, or queen on the same turn
  2. Castling - castling may be performed by moving both the king and one rook by moving the king two squares towards the rook and moving the rook to the other side of the king if both the king and the rook have not yet been moved, there are no pieces between the king and the rook, and the king is not in check, will not end up in check, and none of the pieces it passes through are attacked by enemy pieces
  3. En Passant - if during the last turn, the other player moved a pawn two squares, the pawn may be captured by the player's pawn as if the pawn had only moved one square

States

The following states are non-terminal and allow the game to continue:

  1. Normal - the player may move following the normal actions
  2. Check - the player must get out of check by moving any piece

The following states are terminal and the game immediately ends:

  1. Checkmate (win/loss) - the king is in check and no moves can be made to get out of check
  2. Stalemate (draw) - the king is not in check, but there are no legal moves which can be made
  3. Threefold repetition (draw) - the board has repeated three times in the game (need not be consecutively) with the same player to move, the same en-passant possibility, and the same castling rights
  4. Fifty move rule (draw) - fifty moves have passed without a pawn advancing or a piece being captured
  5. Insufficient mating material (draw) - there is not enough mating material to force a checkmate, this occurs when it is a lone king against a long king, king and knight, or king and bishop

About

Chess game with one or two players. In either mode, only valid moves can be performed. In one-player mode, minimax alpha-beta pruning is used to determine the computer's moves.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published