GithubHelp home page GithubHelp logo

dobro / binbo Goto Github PK

View Code? Open in Web Editor NEW
119.0 6.0 12.0 438 KB

Chess representation written in Erlang using Bitboards, ready for use on game servers

License: Apache License 2.0

Makefile 0.23% Erlang 99.75% Batchfile 0.02%
chess chessboard chessboard-representation bitboards magic-bitboards erlang otp-library binbo chess-game erlang-chess

binbo's People

Contributors

dobro avatar nextchessmove avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

binbo's Issues

Get underlying bitboard (possibly as a list?)

Hi, I am potentially looking to use this library for data analysis purposes in tandom with Nx libraries. I was wondering if there is a function I missed for getting the underlying game state as a bitboard. Thanks!

Engine over TCP

I love this library! Thanks for the great work.

I wonder if it's feasible to make use of an engine over TCP, such as stockfish in a docker container, hosted or otherwise.

Alternately I think I could co-locate binbo and stockfish in one container together.

Validating FEN with 3 rooks on the board

Greetings, and excellent library!

I think I ran across an issue with validating FEN when there are three rooks on the board:

iex(1)> :binbo_game.new("r3k2r/2p1qppp/p3p3/n2n4/P2P4/P2QPNP1/1p1N1PBP/2r1RRK1 b kq - 0 1")                
{:error, {:castling, {:black, :both_sides}}}

That position results from the pawn at c2 advancing to c1 and under-promoting to rook.

I'm not confident enough in my Erlang to submit a pull request, but I think it may just be a matter of changing line 1011 of src/binbo_position.erl from:

case IsKingOnPlace andalso (RooksBB =:= (SqABB bor SqHBB)) of

to something like:

case IsKingOnPlace andalso (RooksBB band (SqABB bor SqHBB)) =:= (SqABB bor SqHBB) of

So, instead of testing, in the case of black, "does black have exactly two rooks and are they on a1 and h8", instead test "does black have a rook on a1 and h8".

Improve game state

In a game. Can we improve on the game state so that if binbo:game_status(Pid) prints the result in a more chess idiomatic way. for example instead of replying {:ok, checkmate} something like {:ok, white_wins} perhaps we can even add a verbose option to binbo:game_status. or just add a new command binbo:game_result() #=> {:ok, white_wins} or if no result {:ok, nil}

Decouple Chess Functionality from Process Architecture

Hey Sergei,

My name is Grant, I'm an Elixir Developer out of Atlanta.

I'm reading through this project and it looks awesome. I appreciate you doing the work and making this public!

I'm working on a project for students to write chess bots and play against each other. I'm hoping to have my own process architecture, from my limited understanding of the docs right now, it seems that a binbo game is coupled to a process. I'm open to doing the work of splitting out the chess functionality from the process structure. My end goal would be to have a set of pure functions that can represent a chess game that I can plug into any process architecture.

My questions
1.) Do you have any guidance that would make this easier?
2.) Would you accept a PR that split out the process structure from the chess functionality?

Best,
Grant

50 move rule

I think that the 50-move rule isn't being applied correctly. From Wikipedia, I'm reading that:

The fifty-move rule in chess states that a player can claim a draw if no capture has been made and no pawn has been moved in the last fifty moves (for this purpose a "move" consists of a player completing a turn followed by the opponent completing a turn).

Binbo is currently looking at halfmoves instead of fullmoves:

 is_rule50(Game) ->
    case (get_halfmove(Game) < 50) of
        true  ->
            false;
        false ->
            case (get_fullmove(Game) < 75) of
                true  -> false;
                false -> true
            end
    end.

So I think it's as simple as this:

is_rule50(Game) ->
    get_halfmove(Game) >= 2 * 50.

Regarding the 75-move rule, I'm not sure it applies here. If I'm understanding the rules correctly, at 50 full moves without a pawn movement or capture (halfmove clock = 100), either player can (but does not have to) claim a draw, whereas at 75 full moves without a pawn movement or capture (halfmove clock = 150), the draw is mandatory.

Let me know if you agree, and if you'd like me to attempt a pull request with tests! Binbo is great and I'm learning a ton from it.

Distribute via Hex

It'd be awesome if this package was distributed via Hex so it could easily be incorporated into projects.

Thanks!

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.