Comments (4)
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.
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.
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.
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)
- Documentation incorrect for chess.Board.turn HOT 1
- board.mirror() HOT 1
- flipping the board HOT 1
- is_variant_draw seems not to work properly HOT 1
- getting `chess.IllegalMoveError` despite the fact that move is legal HOT 5
- always castling rights for clean_castling_rights()
- Incorrect perft(4) with Kiwipete. HOT 3
- impossible to get the moves in san format after pushing the move
- [feature request] add `board.san_move_stack` similar to `board.move_stack` to get san format moves HOT 1
- Is this expected or simply a bug? HOT 1
- Using limit(mate=mate) terminates search before mate HOT 3
- Exception in callback Protocol._line_received('') HOT 1
- CancelledError and TimeoutError when using multithreaded Stockfish to analyze certain sequence of board positions. HOT 1
- Feature request: new argument for chess.svg.board() HOT 1
- engine.analyse() exits with TimeoutError exception HOT 2
- Parsing a database with `read_game` results in roughly 2 extra results per game
- `illegal san` error message when the first game in a database contains a move in the White or Black header HOT 4
- Illegal san, but legal uci move leading to two black kings? HOT 1
- epd parser issue when given a fen HOT 1
- en passant target square not populated when pawn moves 2 sqares HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-chess.