Giter Site home page Giter Site logo

chess-rules's Introduction

Chess

A Ruby Gem to validate Chess moves and (eventually) produce algebraic and FEN notation

Installation

Chess is not yet on Rubygems, due to the early state of its development and the prescene of a blank gem with a conflicting name

The best way to install Chess is using Bundler. Add the following to your Gemfile

gem 'chess', :git => 'http://github.com/edpaget/chess-rules.git'

Usage

Chess is mainly intended to validate chess moves, so it should be used by creating a new Chess game (either blank or with moves given to), and then feeding moves that need to be validating into the game.

Create a new game as follows

Chess::Game.new() # Blank Game
Chess::Game.new( :game => [['e2e4', 'c7c5'], ['g1f3', nil]]) # Game with moves already made

The format for feeding moves into the game is group half-moves into an array of all the full-moves. If white made the last move, black's next half-move should be marked as nil.

You can then make moves by calling the #move method on a game

game = Chess::Game.new()
game.move 'e2e4'

If a move is not legal one of three errors will be raised

Chess::IllegalMove # if a move cannot be made by a piece or if it will put the mover's king in check
Chess::WrongColor # if a move will move a piece by the color that made the previous move
Chess::NoPieceOnSquare # if there isn't a piece on the square to be moved from 

Dependencies

Chess only depends on rspec for running its test suite.

Chess is not currently compatible with Ruby 1.8.7, but has been tested on both 1.9.2 and 1.9.3

Future Directions

The main move forward with Chess will be to include support for output to various notation formats including algebriac notation and FEN notation.

I also plan to add support for detecting more endgame conditions such as the fifty move rule, perpetual check, and 3-move repetition draws.

chess-rules's People

Contributors

edpaget avatar goldenchrysus avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.