Giter Site home page Giter Site logo

Comments (4)

niklasf avatar niklasf commented on May 19, 2024

Yeah, I am not really happy with that.

  • There should be more documentation. Does the README help a little? Is there something specific I can help you with?
  • I am considering to try to rewrite it in pure python, which would be more portable (in a way) and easier to install, hack and use. In fact this was a pure python project, originally, but awfully slow. The problem was that I didn't really want to accept any "hacks" for performance. It should be possible to create a pure python version that is relatively fast and still has a clean API.

from python-chess.

pitchforks avatar pitchforks commented on May 19, 2024

Does the README help a little?

Of course it does, but this is just a first short introduction. To learn the full potential of the API, one still has to dive into the docs (or at least read the docstrings in the source code).

Is there something specific I can help you with?

Perhaps you should know what am I expecting from a python chess library.

Anything you can do with a real wooden chess board: put pieces on it, one by one (this means the starting position as well as any other), be able to move them, move validation checks.

A virtual chess board would also have some additional features:

  • report the current position as FEN string. This is Position.fen, according to the README
  • report the current position as "human visible" board, think of something like Position.get_board() that will return something like https://gist.github.com/pitchforks/10953810 . This is the reason I tried to look closer at the API and realized there are no docstrings.
  • be able to load a whole position at once, from a FEN string, README documents this as well
  • save the history of moves to provide back/forward functionality. I couldn't find this
  • provide a list of possible moves in a position. This is Position.get_legal_moves() and it makes this library particularly appealing for a reason that I'm going to mention below

Fixing the build was a good first step. Adding some docstrings would be a good next step. Doing this will certainly help even if you decide to rewrite the whole thing in pure Python later. And will prevent future complaints about lack of them from people like me :-)

A couple of years ago I have found http://arainyday.se/projects/python/ChessBoard/ and played a bit with it, but ultimately had to give up, because:

  • it looked like being abandoned by its author (and still looks abandoned to this day)
  • it had bugs
  • it had no tests at all, which made it absolutely impossible to attempt modifying the source code
  • it lacked what's named Position.get_legal_moves() in python-chess

There seems to be a big gap in the python world when it comes to chess, perhaps python-chess could fix it by providing a feature rich virtual chess board with an user friendly well documented API.

from python-chess.

niklasf avatar niklasf commented on May 19, 2024

In the last weeks I made a lot of progress with the pure Python rewrite and documentation. Except from the human readable board notation pretty much everything is included.

As always, the documentation could be more thourough, though.

Careful when updating: At this stage it is more important to me to get things right, so I completely ignored backwards compability and broke it all over.

from python-chess.

niklasf avatar niklasf commented on May 19, 2024

The latest version also features some basic ASCII printing, which makes debugging a bit easier.

>>> board = chess.Bitboard()
>>> board
Bitboard('rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1')
>>> print board
r n b q k b n r
p p p p p p p p
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
P P P P P P P P
R N B Q K B N R
>>> board.attackers(chess.WHITE, chess.F3)
SquareSet(0b101000001000000)
>>> print board.attackers(chess.WHITE, chess.F3)
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . 1 . 1 .
. . . . . . 1 .

from python-chess.

Related Issues (20)

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.