Python Chess



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 the latest version,  Once unzipped, run with your favorite Python interpreter.  Prerequisites are Python and Pygame.  Tested with Python 2.6 and 2.4, Pygame 1.8.1.

Development History

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.


  • Maccy  On December 1, 2009 at 4:16 AM

    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. :)

    • yakinikuman  On December 3, 2009 at 7:09 AM

      Do you have a link to it? I’ll put it up here for reference.

  • yakinikuman  On January 27, 2010 at 3:17 PM

    Garry Kasparov, chess grandmaster made famous from his dueling with Deep Blue a decade ago, wrote a fascinating article on chess and computing.

  • yakinikuman  On October 27, 2010 at 4:52 PM

    I just found out someone created a homebrew chess game for PSP which uses some of my code. Awesome!

    If anyone else has used Python Chess code in their own projects, I would love to hear about it.

  • Dan  On November 28, 2010 at 3:35 AM

    I want to use your program on my
    It is a online chess program ?

    • yakinikuman  On November 30, 2010 at 9:47 AM

      No, it is not an online program. You have to download Python Chess, Python, and Pygame for it to work.

  • Dipz  On May 6, 2011 at 1:27 AM

    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.

  • Dipz  On May 6, 2011 at 1:38 AM

    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\”, line 65, in
    from ChessBoard import ChessBoard
    File “C:\Documents and Settings\Alan\Desktop\PythonChess\”, line 84
    def ConvertToAlgebraicNotation(self,(row,col)):
    SyntaxError: invalid syntax

  • yakinikuman  On May 6, 2011 at 8:23 AM

    @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

    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!

    • yakinikuman  On May 6, 2011 at 8:24 AM

      To get to the command line in windows, run “cmd.exe”

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

%d bloggers like this: