Git Product home page Git Product logo

chess's Introduction

command-line-chess

Chess is a Ruby program played on the command line. It's a two player game where players have the option to start a new game or continue a saved previous match.

Getting Started

These instructions will get you a copy of the project up and running on your local machine.

Prerequisites

To work with ruby programs you will need to install Ruby.

Installing

  1. On GitHub, click on the clone or download button and copy the URL.
  2. Open your command prompt /terminal.
  3. Change your current working directory to the location you want to save your project in.
  4. Type git clone and paster the URL you copied earlier:
$ git clone https://github.com/tfb34/battleship.git
  1. Press Enter. You should now have a copy of the project on your computer.

How to Play

To start the game, you must run the program in terminal :

$ ruby main.rb

Two players are needed to play. The program will ask users to enter 1 or 2 if they wish to start a new game(1) or continue game(2).To move a chess piece, player must find the column letter and row number of chess piece.
Example:
Let's say Jin wants to move his pawn at d2 to d4. He must type 'd2 d4' and then hit enter. The move is valid, therefore the next player can go.

Otherwise, the player will be prompted for another move

End Game
  • checkmate
  • player resigns
  • save
  • draw; if there's a draw, flip a coin for now

Two-Move Checkmate

For player to resign, player must type resign , at his/her turn.


To save game, a player must type save , at his/her turn. A player may start from a loaded game, by entering (e.g. steins) when prompted, but has the option of overwriting current loaded game or saving a new file.

Chess Refresher

Rook(a1) : moves horizontally and vertically any number of unoccupied squares. *
Knight(b1) : moves in an L shape in any direction. From b1, the knight has only 2 locations it can move to, a3 or c3.
Bishop(c1) : moves diagonally any number of unoccupied squares in any direction. *
Queen(d1) : moves horizontally, vertically, and diagonally for any number of unoccupied squares in any direction.*
King(e1) : moves to an adjacent square in any direction. At the moment, castling is not an option. *
row 2
Pawn(c2) : moves forward 1 square at a time. May move diagonally 1 square, only if it's capturing an enemy. Cannot capture an opponent directly in front of it. Only on its initial move, may pawn move forward 2 squares.

* At the start of game, chess piece may not move anywhere because all possible paths are blocked by another chess piece.

Illegal moves

If a particular move exposes the king, or would put the king in check, then the program will prompt you for another move.

Promotion

If a pawn makes it to the very opposite end of the board(row1 or row8), it will be promoted. The program will prompt user to enter queen, rook, bishop, or knight. The pawn on the board is then replaced with the player's choice.

For more information on chess visit wikipedia page

Tips

If you do not see the chess pieces as they appear in the pictures above, you may need to go to command prompt settings and change the font. On Windows, change the font to DejaVu Sans Mono.

Built With

  • Ruby - The programming language used
  • YAML - The data serialization language used to store saved games

chess's People

Contributors

tfb34 avatar

Stargazers

Arman Mirzaei avatar

Watchers

 avatar

Forkers

amosjune

chess's Issues

The chess board is set incorrectly

i know this is an old repo lol but the chess board is set incorrectly, the queen goes on its color and king goes opposite color, white queen on white tile.

anyways its wrong here. king and queen are swapped, because
image
as you can see the files for black are alphabetical (a, b, c, d) while they should be opposite. seems easy to fix might try it myself

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.