dorkhub

chess

A fast chess library that use bitboards to play chess with Ruby

pioz
C6319 forksLGPL-3.0updated 1 month ago
git clone https://github.com/pioz/chess.gitpioz/chess

Chess

build codecov

A fast Ruby gem to play chess with Ruby. This library is quite fast because manage game situations with bitboards. Also, the move generator is written in C as a Ruby extension.

Requirements

  • Ruby 3.4 or higher

Installation

gem install chess

Usage

require 'chess'

g = Chess::Game.new
until g.over?
  begin
    print "Give me a #{g.active_player} move: "
    input = gets.chop
    break if input == 'quit'
    g << input
    puts g
    puts g.moves.last
  rescue Chess::IllegalMoveError => e
    puts 'Illegal move!'
  end
end
puts g.status

📚 Documentation is available here.

Questions or problems?

If you have any issues please add an issue on GitHub or fork the project and send a pull request.

Copyright

Copyright (c) 2024 Enrico Pilotto (@pioz). See LICENSE for details.

more like this

urge

The Universal Ruby Game Engine (URGE) Project

C++50

cc65-Chess

Portable chess game in C. Commodore 64, Apple 2, Atari, Oric, Commander X16, curses terminal, etc.

C50

search

search projects, people, and tags