Python Chess

pythonchessv07

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

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.

10 responses

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

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

  2. 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

  3. 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.

  4. I want to use your program on my http://www.chessplayer.ro
    It is a online chess program ?

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

  5. 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.

  6. 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 SettingsAlanDesktopPythonChessPythonChessMain.py”, line 65, in
    from ChessBoard import ChessBoard
    File “C:Documents and SettingsAlanDesktopPythonChessChessBoard.py”, line 84
    def ConvertToAlgebraicNotation(self,(row,col)):
    ^
    SyntaxError: invalid syntax

  7. @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!

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

What do you think?

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

WordPress.com Logo

You are commenting using your WordPress.com 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

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: