Skip to content

briHalterman/ruby-chess

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ruby Chess

A Ruby-based CLI chess game built as the final project for The Odin Project’s Ruby course, with a strong focus on TDD. This project deepened my understanding of object-oriented design and disciplined Git workflows, and was developed using AI tools like ChatGPT to support iterative problem-solving.

Goals

  • Two-player CLI chess game
  • Validates legal moves
  • Detects check/checkmate
  • Save/load functionality
  • Disciplined Git and testing workflow

Minimum Playable Version of Chess

Objective

Place the opponent's king under attack with no legal move to escape (checkmate).

Basic Rules

Initial Position

White is on right! Queen always goes on her color First row: rook, knight, bishop, queen, king, bishop, knight, rook Second row: pawns

setup.jpg

Players & Turns:

  • Two players (white and black)
  • White moves first
  • Players alternate turns

Pieces:

Each side begins with:

  • 1 King
  • 1 Queen
  • 2 Rooks
  • 2 Bishops
  • 2 Knights
  • 8 Pawns

Legal Moves:

  • A piece does not move through other pieces (except Knight)
  • It does not capture its own pieces
  • It does not put or leave the player's king in threat of capture (check)
Rook

Rook movement

King

King movement

Bishop

Bishop movement

Queen

Queen movement

Knight

Knight movement

Pawns
  • The pawn does not move backward
  • On their first move, pawns can move forward 2 squares, after that they can only move forward one square
  • The pawn is the only piece that captures diagonally

Pawns movement Pawns: morning coffee

Stretch Goals

  • Stalemate
  • Castling
  • En passant
  • Pawn Promotion
  • Draw by repetition or 50-move rule
  • Play against the Qwerty

Initial Classes

Board

  • Attributes
    • 8x8 grid data structure
    • Current position of all pieces
  • Methods
    • Initializes board with pieces
    • Moves a piece
    • Displays the board in the CLI

Piece

Subclasses for each type:

  • Attributes
    • Position
    • Color
  • Methods
    • Validates moves

Game

  • Attributes
    • Board
    • Players
    • Current player
    • Game state
  • Methods
    • Handles main game loop
    • Toggles players
    • Determines check/checkmate
    • Ends game

Player

  • Attributes
    • Player color
    • Player name
  • Methods
    • Prompts and receives input

Images sourced from the U.S. Chess Federation and used for educational purposes under fair use.

About

A TDD command-line chess game built in Ruby.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages