This project is from Ruby curriculum at The Odin Project.
Welcome to Ruby Chess! This project is a command-line implementation of the classic game of chess, written in Ruby. It offers a simple yet engaging gameplay experience where you can play against a computer opponent or against another human player. I wanted to create UI similar to chess.com so I split each turn in 2 parts. You can quit or save game at any point.
- 2-player game with legal moves.
- Save and Load game.
- Testing of important methods.
- Computer player
- King cannot move into or ignore check
- Castling is only legal if:
- King is not in check
- Neither piece has moved
- King will not move into check along the path to its destination square
- En passant is only legal immediately following opponent's two-square pawn move
- Checkmate if player to move has no legal moves and their King is in check
- Stalemate if player to move has no legal moves and their King is not in check
- Resignation if player decides to quit the game
- Threefold repetition if position has occured three times, including the
following considerations:
- Same player to move
- Same castling rights
- Same en passant rights
- Draw if during the last 50 moves no capture or pawn move has occurred
If you want to play this game without installing it on your computer, you can
play it online. Just click the
run
button at the top of the page. It will take a few seconds to load the
dependencies and then the game menu will appear.
- ruby >= 3.0
- vs code or windows terminal have font set that supports chess symbols(like DejaVu Sans Mono)
- Clone this repo (steps)
- Navigate into this project's directory
cd ruby_chess
- Run
ruby lib/main.rb
, to start game. - Select mode of playing from 1-player , 2-player or one of the game saved before.
- Each turn have two steps.
- First to select coordinates of piece and Second to select coordinatesof legal move or capture.