Skip to main content

Python Chess - 0.7

Chess for 0, 1, or 2 players


Steve Osborne
(yakinikuman)
Python Chess is a chess game (duh) 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. See the website for detailed development history.

Changes

v. 0.7 - Dramatically lowered CPU usage by using pygame.event.wait() rather than pygame.event.get(). (Woops...)

Links

Home Page
http://uniformlyuninformative.wordpress.com/games/python-chess/
Source
http://sites.google.com/site/purplesaguaroinc/myfiles/PythonChess_v0.7.zip

Releases

Python Chess 0.6 — 21 Apr, 2009

Python Chess 0.5 — 16 Apr, 2009

Python Chess 0.7 — 28 Apr, 2009

Pygame.org account Comments

  • Alex Kagioglu 2012-10-13 02:24

    sweet chess game. the defense ai is fun to play but not challenging.

    alia khan 2015-11-29 10:24

    hey ..we have the same code..
    i just want to know how did u run the code..
    bcoz i have some problem to run it..plzz can u help me???
    give me answer as soon as possible...

  • Alexandre Pinho 2013-09-11 16:59

    Good start but cannot castle, the AI doesn't open very well and cannot defend against mate in 1 move.

  • Fran 2014-01-11 20:29

    The program looks cool but I don't know how to start it. A little problem ;) <3

    Michel Lavoie 2019-06-26 00:14

    Hello, You just have to run the file " PythonChessMain.py" in your favorite interpreter (e.g., spyder). You must have python 2 however or a python 2 environment on your computer. When you run the file , you will see a chess game. Then, you can click on pieces you want to move
  • Thomas Dybdahl Ahle 2014-02-13 12:25

    Also have a look at PyChess: http://pychess.org If you are looking for a nice chess client for Linux written in Python.

  • Joel S Wilson 2014-03-17 14:54

    I want to See Raspberry Pi 2 or more PI to play each other is that possible - Can some one upload the code - thank you - please email me joel367@gmail.com - I want it on game repeat so it might learn

  • Shashaank 2015-03-22 05:39

    The castle option is not there. Is there an updated version of this? And I wanna start understanding the code. From which file should I start?

  • Sarainia Krystal-Rose Angelson 2015-10-15 01:22

    I more or less wanna learn how to program any chess program the problem is I have no prior knowledge to any programming language at all! Now I sorta know batch scripting from windows command prompt but I doubt I can make any headway with that and even if I did then it likely still not be clickable and user friendly and graphical etc. so if anybody is up to giving me free chess programming lessons in any programming language you see fits best then lets hook up via online like email, facebook, skype etc. and lets work on this journey together! There are lots of chess programming in C/C++ for dummies stuff on web and in books but I want a more human interaction while learning to program rather than a cheesy sit and watch a video on youtube or reading a book or sifting through a website like c'mon really I would benefit more off with a human teaching me and since there is lots of free tutorials I also request the human provides free time and free cost to teach! Lets do this project together and see if we can even by chance make a program that could even be sellable for example but just getting one to work and to beat Rating 1250 or less players 99% the time would be a cool enough achievement alone! We don't need deep thinking at all maybe max 4 moves deep instead of the usual 15-20 most do! No more than 50,000 nodes! Have our own look to our pieces! have pruning and estimations so that it never exceeds 50,000 nodes! Might as well make a fair Chess program if I gonna learn how to program one and allow myself or anyone to beat it as an example of fairness! To this date there is hardly any fair chess programs that is easy for a human! 90% of all chess engine downloads end up being 1500 to 3000+ in ratings which is not fair and doesn't give source codes in programming languages 99% of the time and if you do then it's a garbled up mess of numbers and characters and letters and values and words that makes no sense at all to attempt reverse engineering on! So if anyone is willing to pair up with me lets start by you replying to this message and we can communicate from this point to start with and then start a programming journey together! You decide the appropriate programming language and the approach we should go! I want it to be clickable and have a very nice feel and look to the game! Have our names on the project! It can be free open source, or free download with encrypted software, or simply a sellable game we split 50/50 or we split 25/25 with each other and 50 to a charity of our choice! For instance Therapy Chess may be a cool one to design for people with brain injuries or are in the Hospital and lots of people have phones so maybe a light weight program that interacts with their mood in a friendly and colorful and soft interface that's not bold or contrasted etc. Have it customization between the 8 colors of the rainbow including "Pink, Blue" for people's gender so if they pass the color choice then it goes to default, displays Real world time along with chess timer! Has small limited book, analyzing software! Like we don't have to do all that at first no lols at first lets just get a working demo of the game up then we can do some of that later on! It's best we swap code around or ping it back and forth because I am new so I will likely get errors because of my newness to it all! Sorry for this chapter of a book :P I have written but yeah I just wanna do something fun and maybe just maybe we can tie it to a more useful thing like a charity or a small business for us or whatever we think of later on kinda thing! The sky is the limit and we don't have to just stop as an example when our small lightweight and fair chess game is up and running! Ultimately my 3 goals are to "Make a chess program and be able to put my name on it" "Make it fair to play against and make it not strong to play against tournaments online this is to weed out cheaters" "lastly turn it into profit for ourselves and or charity" <-- if we do charity might as well make it therapeutic! Anyways cheers! Hope to find someone who understands I know nothing to programming so if we are gonna do this lets please pick a powerful programming language to have the Pleasant GUI that's interactable and at same time the least complex we can possibly make the coding language so that way I have a lot less head scratchers which means less waste of time lols! I sorta started learning C and Python but honestly if you really think we should pick something easier if there is something easier then lets shoot for that and I guess lets start cracking! After this project there is a tiny complex thing I wanna try out and that is the most basic Artificial Intelligence that can like maybe as a basic thing to do is define if 2 colors match or something and maybe analyze an image and see if any colors match or something like as a fun project! Now this doesn't meant I wanna do this directly after we do our chess program nor would I wanna force that onto you the chess program alone would be more than a dream come true and would be happy enough to create something fun like that! Keep in mind the format of our chess doesn't necessarily have to be the same old same old meaning heck we can change the look of the board and or pieces and can still have the exact same functions, movements and strategies! Who says we gotta be the same as every chess program out there right! :3 we can have it built in as a toggle/choice to go to the traditional look and feel for example! Maybe our board as example is a landscape divided by 8 by 8 circles/tiles and maybe on each one of them is some kind of cute animal or empty space as example :3 anyways Cheers!

    DerppyMan 2017-01-21 23:33

    https://uploads.disquscdn.com/...

  • Lata Yadav 2015-11-18 21:48

    in ChessBoard.py - its giving error on line 85

    ConvertToAlgebraicNotation(self,(row,col)):

    saying syntax error .

    Please someone help me resolving it.

    Thanks

    byte 2015-11-19 13:41

    you need to put def in front of it.
    like this, code works fine then.
    def ConvertToAlgebraicNotation(self,(row,col)):

  • alia khan 2015-11-29 10:18

    hello...
    i'm student.. and new comer in python, i don't have any advanced knowledge in this language,,
    ,
    we have downloaded your source code of python chess from this website..

    but we have facing so many troubles..in running this code..we have the following errors...plzzzzz we need help as soon as possible...

    the errors are...

    1)TypeError: ConvertToAlgebraicNotation() missing 1 required positional argument: 'col'

    2)TypeError: text must be a unicode or bytes

    3)TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

    4)NameError: name 'py2exe' is not defined

    5)ImportError: No module named 'py2exe'

    we need your answer urgently...plzz...

    DerppyMan 2017-01-21 23:31

    you have to download the py2exe lol

    Scott Broscious 2016-01-20 16:53

    He may need the line numbers these errors were noted as originating from in order to help. For example:

    Traceback (most recent call last):
    file "file_name_for_your_python_program", line 78, in <module>
    print variable_that_is_None + "Hello World"

    TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

  • DerppyMan 2017-01-21 23:34

    Derp https://uploads.disquscdn.com/...

  • DerppyMan 2017-01-21 23:35

    https://uploads.disquscdn.com/... https://uploads.disquscdn.com/... 01f0e53611e66a83cf33a23ed31664c993154f8e470601.jpg

  • Kunal 2017-09-23 17:33

    What are the artificial intelligence algorithms used in this project?

    Steve Osborne 2018-01-23 05:14

    This blog post discusses the "AI" strategies: https://uniformlyuninformative.wordpress.com/2009/04/16/python-chess-v-05/ It ain't much!
  • jimmy half 2018-06-08 06:14

    there is another very interesting in https://www.albertochueca.com and in addition he offers a very good chess guide...
  • jimmy half 2018-06-08 06:14

    Hi chess
  • Saahil 2018-10-18 18:41

    I want to build my own AI agent on top of the chess simulator. Is it possible to do this over this project? Will appreciate your help and response.