Code Monkey home page Code Monkey logo

top-ruby-chess's Introduction

aliases linter-yaml-title-alias created modified
The Odin Project - Chess
The Odin Project - Chess
Sunday, June 18th 2023, 6:20:15 pm
Monday, July 24th 2023, 11:59:08 am

Chess is the Ruby Final Project for the Odin Project.

To begin with, I'm porting over most of my code from my Knight's Travails solution. I'll be pulling out any code that isn't relevant to the chess game.

Things to Keep in Mind:

The moves of chess are outlined in algebraic notation where:

1. e4 e5

Encompasses all of turn one. 'e4' represents the white piece's move and 'e5' represents the black piece's move. In this case, e represents the 'file' where the movement starts. Because there is no letter designator (K, Q, R, N, B), it indicates that a pawn is being moved, and 4 represents the rank where the piece is ending it's move. So, the white pawn in file 'e' moves forward to rank '4'. Then the black pawn in file 'e' moves forward to rank '5'.

When referencing a piece, the abbreviation for that piece is capitalized for white pieces and lowercase for black pieces per the FEN standard. - K - White King - Q - White Queen - R - White Rook - B - White Bishop - N - White Knight - P - White Pawn - k - Black King - q - Black Queen - r - Black Rook - b - Black Bishop - n - Black Knight - p - Black Pawn

PGN Standard is a plain text format for recording chess games (both moves and related data).

Todo:

Please note, this is a working list of things to do. It will likely change and expand over time.

Changes to Make:

Notes:

This is mostly going to be stuff that needs to be refactored. I'm starting out with a good chunk of code that I wrote for Knight's Travails. The files I'll be using are:

Refactor List:

  • Decouple board from pieces and displays
  • Separate data from code:
    • Create lib/data directory
    • Create standard_initial_setup file that stores the starting piece positions for a standard game of chess
  • piece_handler.rb:
    • need to alter the piece names to use fen standard
    • #add_piece method seems tightly coupled to square.rb - square_handler should probably be called here to swap square's contents
    • Implement custom errors
  • display.rb
    • self.query_for_players
      • Tie in prompts through Messages
    • self.query_for_game_type
      • Tie in prompts through Messages

Features

Needed

  • Implement class objects for pieces
  • Define piece movements (POSSIBLE_MOVES)
    • king
    • queen
    • bishop
    • knight
    • rook
    • pawn
  • executable that runs chess
  • Driver module: ./main.rb
    • requires:
      • board - `./lib/chess/board.rb' controls board object code
        • requires square_handler.rb
          • requires square.rb
      • piece_handler ./lib/chess/piece_handler.rb controls movement, placement, creation and identification of pieces
        • requires chess_pieces(Pieces)- ./lib/chess/chess_piece.rb collection of usable pieces
          • requires chess_piece.rb, king.rb, queen.rb, rook.rb, bishop.rb, knight.rb, pawn.rb
      • display.rb
      • version.rb
  • Game Startup
    • Print game name/version/author info
    • query user for type of game, standard/custom builtin
    • query user for computer vs. player or player vs. player
  • An initial setup of the board state for a standard game of chess.
    • piece positions:
      • a8 - black queen's rook
      • b8 - black queen's knight
      • c8 - black queen's bishop
      • d8 - black queen
      • e8 - black king
      • f8 - black king's bishop
      • g8 - black king's knight
      • h8 - black king's rook
      • a7-h7 = black pawns
      • a2-h2 = white pawns
      • a1 - white queen's rook
      • b1 - white queen's knight
      • c1 - white queen's bishop
      • d1 - white queen
      • e1 - white king
      • f1 - white king's bishop
      • g1 - white king's knight
      • h1 - white king's rook
  • Turn handling (player 1 is always white, player 2 is always black)
    • Player Handling
      • Player Object
  • Load custom starting board setups (yml files only)
  • Input handling
  • Piece removal (on capture) - piece_handler.rb
  • Method of recording moves
  • Method of saving data to file
  • Method of loading data from file
  • Data structure for saving
  • Move tracking

Wanted

  • [[Display]] Board display reversability for 2 player play so 'current player' is always at the bottom of the board facing their opponent
  • Tab completion for moves
  • Tab completion for loading custom game setup
  • Game timer
  • Global options configuration - --board-setup filename.yml - checks for ./lib/data/filename.yml or current directory for filename.yml and loads the board setup from there.
  • ASCII Chess pieces
  • Help system
  • Color indicated squares to visually indicate squares referenced by the game. (ex: Blocked movements, briefly highlighting the square before moving the piece, etc.)

top-ruby-chess's People

Contributors

taladan 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.