Giter VIP home page Giter VIP logo

chess's Introduction

Chess

Created by Ari Weitzman and Tom Bescherer

How to Use

To begin a game, clone the repo and navigate to its path in your terminal window. Then type:

$ ruby index.rb

Choose a name for each player and then begin playing! Moves take the format of "start move-end move" (i.e. "A2-A4").

The game also allows users to save one board state for future use. To save a game state at any time, when prompted for a move just type "save":

A (white): Enter start and end position, divided by a dash: save

To load a previously saved board, type "load":

T (black): Enter start and end position, divided by a dash: load

Technologies

This rendition of Chess is written entirely in Ruby. To add color to the board, we employed the colorize gem.

To simplify movement among the pieces, we created a base Piece class from which all other pieces inherited. This allowed us to avoid redundancy in our code.

In order to evaluate whether a move is valid or not, the program simulates future board states based on the proposed move. If the move would put the moving player in check, or does not obey the rules of movement for the moving piece, we reject the move. To accomplish the future board simulation, we deep dup the board and raise an error to alert the user that the proposed move is not a valid one.

To save board states, we used YAML. The program converts the Board's grid attribute object to YAML and saves it as a text file. When the user loads a game, the program reconstitutes this grid from YAML and passes it to the Game instance.

Requirements

There are two outside gems required

  1. byebug
  2. colorize

If you have bundler, you can install them with

bundle install

because they are specified in the Gemfile

chess's People

Contributors

arijoe avatar tbescherer avatar

Watchers

 avatar  avatar

Forkers

jonmcoe

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.