GithubHelp home page GithubHelp logo

jacobgardner / chessai Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 2.21 MB

Part of my exploration of Rust and how it is good. This is more about exploring patterns and architecture in Rust and less about an efficient Chess AI

Rust 100.00%
chess chess-ai

chessai's People

Contributors

jacobgardner avatar

Stargazers

 avatar  avatar

Watchers

 avatar

chessai's Issues

Allow pawn to upgrade to other pieces

A pawn when hitting the end of the board, may choose to promote to any piece (excluding king and pawn). So technically this move should create a board for each of these other pieces.

I think it would be useless to generate a rook or bishop over a queen, but a knight may be useful, so our move generator should create 2 boards for each promotion (1 queen and 1 knight)

Cleanup Pawn Move Generation

Things needed before calling this done.

  • There's a lot of raw bit manipulation that we can probably turn into inline functions that hide the implementation details
  • En Passant
  • Pulling out more common code into separate functions
  • A few more debug_asserts for invariants.
  • En Passant

Use 45 degree rotated bitboards for bishop/queen move generation

Some notes before I abandoned the initial implementation to get it working quickly.

        // if file > rank, above the diagonal
        // if above diagonal: 8 - (file - rank) = row #
        // if below diagonal: rank - file = row #
        // if file == rank => row = 0
        //
        //  if above the diagonal, indicies are from
        //      8 - row #  to 8
        //  if below the diagonal, indicies are from
        //      0 to 8 - row #

Reconsider Use of Failure

With the std::error trait stuff changes we may not need failure any more. (Especially since failure is going to change in response to it).

Use traits to help make code generic for move_generation.

Rook, Bishop, Knight, Queen, and probably king will all generate moves in more or less the same way. We should probably create a trait that requires each piece to implement generate_piece_moves() so that we can reduce the duplicated code.

Fix multiple workspace snapshots

A test at chess-lib/tests/rook_move_generation.rs

will generate a snapshot file at chess-lib/chess-lib/tests/__snapshots__/rook_move_generation.rs.snap

instead of placing it in a __snapshots__ folder in the same directory. I believe this is because of multiple workspaces.

For SAN, don't over-disambiguate moves

Right now for all notation we specify the piece type, the rank/file of the original space and the rank/file of the destination space, whether it was a capture, promotion, en-passant, or castling. Some of this information is redundant given the previous board state. For example, if two rooks can reach the same space and one moves there, It is common to only specify the rank or file of the rook that moved (I forget which is a higher priority). If only one piece of that type can reach the space, neither the rank or file are specified.

This is how standard algebraic notation works and should probably be followed

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.