This is a two-player Chess and Checkers game suite written in Ruby and played over command line. It makes use of a hand-rolled module, ChessUtils, that encapsulates shared logic between the games and provides an API for developing similar ones.
I wrote this with a strong focus on Sandy Metz-style OOP principles.
Simply download, navigate to the root folder and run ./chess.rb
or
./checkers.rb
. If that doesn't work, try running chmod +x ./chess.rb
.
- Move validation system allows full range of piece trajectories
- Fully playable, with notifications for check and checkmate
- Pieces make use of multi-level class inheritance system for DRY code
- Play against a friend, a computer AI, or watch two computer opponents face off against each other
- Accepts notation for multi-jump sequences - e.g.
a4, c6, e8
- Human and computer players share the same API with duck-typing
Renderable
- Provides full-color GUI for pieces and board
Notatable
- Translates user input from algebraic chess notation to array coordinates
- Uses regex and error handling to validate user input
Traversable
- Provides utility methods for calculating delta coordinates in a 2d positional grid
The checkers AI is definitely one of the coolest features of this suite. Here's how it works:
- Computer AI performs a depth-first search over the tree of all possible move sequences for each piece
- If there are any possible jump sequences, it picks the longest one available (i.e. it claims as many pieces as it can)
- If there are no possible jump moves, it picks the safest slide available (i.e. it plays defensively)
- Otherwise, it makes a random move - unless it's landlocked and can't move, then it forfeits
- Chess AI
- Load and save games
- More extensive chess moves - e.g. castling, en passant, etc.
- Expand Checkers AI move algorithm to take kinging into consideration
- Log and display notated user input on game completion
Ruby Chess Suite is released under the MIT License.
Developed by Chris Sloop