Socket
Book a DemoInstallSign in
Socket

rb_chess

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rb_chess

0.0.0
bundlerRubygems
Version published
Maintainers
1
Created
Source

rb_chess

A chess library written in ruby. It provides all a representation of a chess game with all rules and serialization. It also provides a command line interface for playing the game

Installation

Add this line to your application's Gemfile:

gem 'just_chess'

And then run:

$ bundle

Or install it yourself as:

$ gem install rb_chess

Features

  • Supports all chess moves including:
    • En passant.
    • Castling.
    • Pawn promotion.
  • The game detects and declares:
    • Checkmate.
    • Stalemate.
    • Insufficient material.
    • Fivefold repetition
    • Seventy five moves rule
  • Move generation.
  • Move validation.
  • Serializing (json and binary).

Usage

The code below plays a random game of chess:

require 'rb_chess'

game = RbChess::Game.new

until game.game_over?
  puts game.board.ascii
  game.make_move(game.all_moves.sample)
end

puts game.board.to_fen

You can find the full example of using this library in the RbChess::CLI class in lib/rb_chess/cli/cli.rb.

Playing

  • To start run rb_chess.
  • Moves are made by typing in coordinate system i.e e2e4.
  • Castling moves are made by typing 0-0 for kingside and 0-0-0 for queenside.
  • Promotion moves are made by typing the move with the promotion piece after it e.g a7a8Q.
  • To save type save or s.
  • To quit the game type exit.

To do

  • Support for PGN.
  • Support for SAN move format.

License

Distributed under the MIT License. See LICENSE for more information.

FAQs

Package last updated on 17 Mar 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.