aliases | linter-yaml-title-alias | created | modified | |
---|---|---|---|---|
|
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.
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
- Look up PGN (Portable Game Notation) stuff
PGN Standard is a plain text format for recording chess games (both moves and related data).
Please note, this is a working list of things to do. It will likely change and expand over time.
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:
- bishop.rb
- board.rb
- chess_piece.rb
- display.rb
- king.rb
- knight.rb
- pawn.rb
- piece_handler.rb
- queen.rb
- rook.rb
- square.rb
- square_handler.rb
- 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
- self.query_for_players
- 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
- requires square_handler.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
- requires chess_pieces(
- display.rb
- version.rb
- board - `./lib/chess/board.rb' controls board object code
- requires:
- 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
- piece positions:
- Turn handling (player 1 is always white, player 2 is always black)
- Player Handling
- Player Object
- Player Handling
- 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
- [[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.)