A modern web implementation of the classic "Long Backgammon" board game, built with the cutting-edge Ruby on Rails 8 stack. This project combines traditional rules with the high interactivity of a modern single-page application.
- Complete Ruleset: Implemented full game logic including counter-clockwise movement, the "Head" rule (one checker per turn), "Block" rule (no 6-checker barriers unless the opponent has passed), and bearing off logic.
- SPA Experience with Hotwire: Utilizing Turbo Streams and Stimulus JS to provide a seamless experience without page reloads. Moves and dice rolls are updated instantly.
- Fully Responsive Design: The game board automatically scales to fit any screen size (Desktop/Tablet/Mobile) while maintaining its aspect ratio, powered by Tailwind CSS 4.
- Victory Celebration: Interactive fireworks animation using the
canvas-confettilibrary when a player wins. - Server-Side Integrity: All game logic and move validations are performed on the backend, preventing cheating via browser console manipulation.
- Backend: Ruby 3.2+, Rails 8.1.1
- Database: SQLite (storing board state as JSON)
- Frontend: Hotwire (Turbo + Stimulus), Tailwind CSS 4
- Asset Pipeline: Propshaft + Importmaps (Zero-Node.js build)
- Animations: canvas-confetti (ESM)
- Initial Setup: Classic Long Backgammon starting positions (15 checkers on the "Head").
- Dice Logic: Random generation with support for "Zari" (doubles), granting 4 moves instead of 2.
- Head Rule: Restriction on taking more than one checker from the head per turn (except for the very first double of the game).
- Blocking (Prime): Prevention of building a 6-checker barrier if the opponent hasn't passed that section yet.
- Smart Turn Switching: Automatic turn transition if a player has no legal moves available.
- Bearing Off: Ability to remove checkers from the board only after all 15 checkers have entered the "Home" area.
To run this project locally:
-
Clone the repository:
git clone https://github.com/your-username/backgammon.git cd backgammon -
Install dependencies:
bundle install
-
Prepare the database:
bin/rails db:prepare
-
Start the development server (includes Tailwind watcher):
bin/dev
-
Open your browser at:
http://localhost:3000
Built with ❤️ and respect
