Giter Site home page Giter Site logo

chess's People

Contributors

nickjamesio avatar

Watchers

 avatar  avatar

Forkers

miyanda2

chess's Issues

Refactor board class to use Fen obj

When creating a Board object, it should accept a Fen obj. If no Fen object is passed in, create empty board, else, assign pieces where they belong.

Remove has_moved from Piece class

Remove has_moved from Piece class

  • Only really care about pawn, king, and rook movement
  • Pawn can move two forward if have not moved yet
  • King can castle left or right if it has not moved and the rook on that side has not moved

Approach

  • Allow move_directions in Piece class to be set by outside classes
  • move_piece would update the following pieces
    • pawn to 1 position forward once it has moved
    • king to 1 position left/right once it has moved
    • king 1 position left when left rook moves
    • king 1 position right when right rook moves
  • Check for castling
    • check king move_directions left/right
    • if == 2 for that direction, we know king has not moved and rook in that direction hasnt moved

Break tests into smaller tests

Test cases from PieceMovementTest can be moved into other test files to make this file smaller and more targeted.

Ex. There could be one file for capturing, another for legal moves, another for moving pieces

Make use of properties

All classes currently have getter and setter methods. Refactor them to use properties.

Remove last_move field. Replace with en passant target position

I want to make use of the EPD notation to setup a game board. As part of of the notation, you can specify the position a pawn could move to in order to perform an en passant move. It does not let you know if en passant is possible though. There may not be an opponent pawn present to take advantage. Basically it always points to the square right behind a pawn that just moved forward two spaces. In the following example EPD string, the g6 square is the target en passant position

rnbqkbnr/pppppp1p/8/6pP/8/8/PPPPPPP1/RNBQKBNR w KQkq g6

Each time a pawn moves two spaces, a the en_passant_target_position field would be updated to contain the en passant target position. If there is an opponent pawn to the left or right of the pawn that just moved two, en passant is possible. If not, en passant not possible. Each time a piece other than a pawn moves, the en_passant_target_position field will be set to None

See http://portablegamenotation.com/EPD.html for more info

Create MoveResult class

Create method and test for this

  • Positions that are now empty due to capture
  • Positions that are occupied by piece that moved
  • Pawn to be promoted. Which position, color, piece types that can be used in promotion

Create test case for ChessGame class

ChessGame class needs some tests

move_piece()

  • Did fen field update correctly
  • Does MoveResult contain pawn promotion position when expected
  • Does MoveResult contain correct king in check
  • Does MoveResult contain correct king in checkmate
  • Does MoveResult contain correct value for draw
  • Does MoveResult contain correct value for updated positions
    • Check when no capture
    • Check when regular capture
    • Check when enpassant
    • Check when castle

current_player()

  • Confirm correct player obj is returned with correct color

get_winner()

  • Does it return the correct user with correct color
  • Does it handle case where the is no winner yet
  • Does it handle case when there is a draw

Add exceptions for when a position is not valid

Many methods in ChessBoard class accept an algebraic notation as an argument. These methods assume the value passed in is valid. Exceptions should be thrown when the value is not correct.

Create a GameState class

Implement GameState class. This will be useful when writing a UI. GameState object should let the UI know what is happening. State can be queried from ChessGame class

Return following info

  • If King in check and which king
  • If King in checkmate and which king
  • If draw occurred
  • The king that is in check or checkmate. Color, position
  • Winner. Player id, player color, player name

Update all test in PieceMovementTest to try both black and white pieces

I discovered a bug where all movement was programmed from white's perspective. All movement offsets, such as forward, are relative. So if you tried to move a black piece forward, it would actually end up moving backwards. The bug was fixed but test need to be updated to confirm all cases work and prevent future regressions.

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.