Features
Chess for player vs. player, player vs. AI, or AI vs. AI. Uses Tkinter to get initial game parameters. Uses Pygame to draw the board and pieces and to get user mouse clicks. Run with the “-h” option to get full listing of available command line flags.
Python Chess has a Pygame website page, too.
Download
Download the latest version, PythonChess_v0.7.zip. Once unzipped, run PythonChessMain.py with your favorite Python interpreter. Prerequisites are Python and Pygame. Tested with Python 2.6 and 2.4, Pygame 1.8.1.
Development History
- Python Chess, Version 0.1. April 1, 2009
- Python Chess v. 0.2 – Making code pretty. April 5, 2009
- Python Chess v0.3 – Display and UI with Pygame. April 6, 2009
- Python Chess v 0.4 – Better graphics, Tkinter. April 14, 2009
- Python Chess, v 0.5 – Improved AI. April 16, 2009
- Python Chess, v0.6 – Compatibility Fixes. April 21, 2009
- Python Chess v 0.7 – Lowering Pygame’s CPU Usage. April 28, 2009
Yes, the final version is 0.7. I started at 0.1 and incremented from there as I thought of new features. The project seemed pretty complete (to me) after about v. 0.5 or so.

Comments
Hello. I was using your source for creating my own board game. While doing that, I cleaned up alot of your source code/removed unneccesary stuff. If you want me to, I could send the cleaned code to you for future reference.
Do you have a link to it? I’ll put it up here for reference.
Garry Kasparov, chess grandmaster made famous from his dueling with Deep Blue a decade ago, wrote a fascinating article on chess and computing. http://www.nybooks.com/articles/23592
I just found out someone created a homebrew chess game for PSP which uses some of my code. Awesome! http://www.psp-hacks.com/file/1718?id=1718
If anyone else has used Python Chess code in their own projects, I would love to hear about it.
I want to use your program on my http://www.chessplayer.ro
It is a online chess program ?
No, it is not an online program. You have to download Python Chess, Python, and Pygame for it to work.
Hi, I’m new to python and am struggling to run PythonChess – I have python and pygame, open up idle and attempt open the Main, but it has issues when trying to run the code. I’m probably running into an obvious flaw, but would you mind guiding me in the right direction, if you’re still around.
Apologies for the double post but here is the error it gives: (thing is I don’t know a thing about the syntax of python…)
Traceback (most recent call last):
File “C:\Documents and Settings\Alan\Desktop\PythonChess\PythonChessMain.py”, line 65, in
from ChessBoard import ChessBoard
File “C:\Documents and Settings\Alan\Desktop\PythonChess\ChessBoard.py”, line 84
def ConvertToAlgebraicNotation(self,(row,col)):
^
SyntaxError: invalid syntax
@Dipz – I think the problem is you can’t run Pygame from Idle. Try running it just from the command line:
(your python path)\python.exe PythonChessMain.py
Or maybe you have a Python / Pygame version mismatch? Make sure you’re using the 32 bit versions. I’ve just tested it again with Python 2.6.6 and Pygame 1.9.1, both 32 bit versions, on my 64 bit Windows 7 laptop and it seems to work fine.
Good luck!
To get to the command line in windows, run “cmd.exe”