ChessBoard - v2.05
ChessBoard is a Python implementation of the FIDE laws of chess. The main goal is to implement all applicable rules in a simple, straightforward way. The intention is not to be fast but to be easy to understand and to be complete. Many other implementation has known problems with castling, stalemate or other more or less special rules.
The ChessBoard logic is contained in one class with a simple set of public methods.
- The moves of the pieces
- En passant
- Check detection
- Checkmate detection
- Stalemate detection
- Draw by the fifty moves rule detection
- Draw by the three repetitions rule detection
- Get valid locations support
- Import and export of Forsyth-Edwards Notation strings.
- Add text moves in the AN, SAN and LAN standards.
- Export moves in the AN, SAN and LAN standards.
- Undo and Redo.
- Goto a specified move.
What's new in 2.05?
- Fixed a bug in the getFEN() method. (Thanks to Alfredo Alessandrini)
What's new in 2.04?
- Fixed another bug in the setFEN() method. (Thanks to Alfredo Alessandrini)
What's new in 2.03?
- Fixed a bug in the setFEN() method.
What's new in 2.02?
- Added the method getLastMove()
- Changed the behavior of the promotion value. The promotion value set by setPromotion is always remembered until
setPromotion(0) resets it.
- Added the method getPromotion() to get the current promotion value.
- Added the method getLastMoveType() to indicate if the last move was a "special move" like en passant or castling.
- Fixed a bug in getLastTextMove(...). It now returns the correct code for castling.
- Fixed a bug in the addMove() method. It pushed the state before it determined the game result causing it to loose the game result when using undo redo.
What's the use?
With the included example you and a friend can play a game of chess. But that is not the real reason to why I wrote this. Whatever chess software you are planning to write you almost always need to be able to determine valid chess moves and to detect the end of the game. You need this for network games, web based games, chess engines, PGN-viewers, chess training software etc. etc.
Short note about coordinates
ChessBoard preferably use its own internal coordinates in the communication with the client (for example in addMove and getValidMoves). The coordinates starts at (0,0) in the upper left corner. Ex: (0,0) = a8, (7,7) = h1. This is the same coordinate system that is use in the matrix returned by the getBoard method.
New since version 2.0 is that you also can add moves by using Algebraic Notation. The new method addTextMove understands three different standards; Algebraic Notation (AN), Standard Algebraic Notation (SAN, used in PGN-files) and Long Algebraic Notation (LAN).
The popular opening e2-e4 is done by calling addMove((4,6),(4,4)) but can also be made by calling addTextMove("e4"), addTextMove("e2e4"), addTextMove("e2-e4") or addTextMove("Pe2-e4").
- FIDE - Laws of Chess - The laws of chess.
- FIDE about SAN - Standard Algebraic Notation, see appendix E.
- Forsyth-Edwards Notation - Wikiedia about FEN-strings.
- Python - The python programming language.
- PyGame - Game development for Python.
- ChessBoard_2.05.tar.gz - Current ChessBoard version including example and graphics.
- ChessBoard_2.05.zip - Same as the above but in zip-format.
- ChessBoard.py - The core ChessBoard 2.05 module.
- HowToUseChessBoard.txt - Short description of the public methods. Also included in the above package.
- Special thanks to Jasper Stolte for testing and suggesting improvements!
- Chess graphics are released under the Creative Commons License and made by Paul Gorman .
- Source code are GPL and made by me (John Eriksson).
Comment this project:
Max 2012-11-07 00:19:27 gadfium 2012-06-12 04:40:45 gadfium 2012-06-12 04:37:25 gadfium 2012-05-22 04:16:47 gadfium 2012-05-20 03:54:06 View all