ChessPy

June 18th, 2006
Knight

A while ago I wrote a chess module for Python. Now this is not a chess-playing module, rather it parses chess moves, stores board positions and works out legal moves. It can also read and write PGN files. I can fairly confidently declare myself as an expert in this kind of thing, having written the PC chess game Chess Commander.

Chess is something that is very well defined, the rules are laid out in black and white, but there are enough juicy problems and gotchas to make it interesting to work on. It was the special case moves such as en passant and castling that were most tricky. I made extensive use of Python's generators extensively which did simplify things a great deal.

There was already a python chess module in existence, by Eric Max Francis, but this version supports stalemate / draw rules and FEN output. It was originally written just for the hell of it, but I have since decided to dust it off and use it to create an AJAX chess website - which is why I present it here for feedback.

I'd be interested in help with optimization. It was designed to be flexible (ie possibly support chess variations) and speed was a secondary considerations. But if my AJAX chess site is successful it could be doing a lot of processing, so any tips would be appreciated! Although they may be moot since Psyco gives a significant speed boost.

Download Python Chess Module
 

Magnetic Personality

June 12th, 2006

I love this photo I took - it could almost pass for one of those classic computer graphics images with spheres reflecting spheres, that you would see on the walls of students bedrooms in the 90s. Thank you Sony Cybershot!

Magnetic Constructor System
 

Aquarium Antics

June 10th, 2006

Day 2 of my pseudo-holiday led me to the Blue Planet Aquarium, near Chester. Now since I was at an aquarium, you may be expecting pictures of fish. A perfectly reasonable assumption, but you would be dead wrong. It turns out that taking pictures of fish is actually quite difficult to do. The flash reflects off the glass and water, and the little buggers wont stay still. Fortunately there were also bugs* and amphibians to snap.

Stick Insects Spider Frog

*Technically speaking, none of the above are bugs. A 'bug' is actualy an insect with sucking mouth-parts. This is one of those little facts that you can quote verbatim in order to appear smarter than you actualy are. I know I do.

One more blog-worthy event occured today, and that is an encounter with a surley swan. No doubt its ill temper was due to the beetle that was crawling around on its beak.

 

Chester Sunshine

June 9th, 2006

My sister visited to day and it gave me the opportunity to go out in Chester and take a few photos with my digital camera. Im not going to bore you with tourist snaps, I'm going to bore you with pretentious arty photos.

Cracked Mirror Blue Beads Guiness Gothic Railing
 

Behind the Back

June 4th, 2006

I recently mastered behind the back throws. What? You don't believe me?! Well screw you buddy, I have video evidence.

 

Blooming Cactus

June 4th, 2006

My cactus is in bloom. That's all I have to say about that.

Cactus
 

Python Netstring Module

June 4th, 2006

Netstring.py’ is a Python module to encode / decode netstrings. A netstring is a simple protocol for encoding arbitrary strings in a file or datastream. They have the major advantage over the traditional zero terminated strings in that the reader knows the size of the string up front and does not have to examine the data a byte at the time.

There is no documentation for this module other than the docstrings, but hopefuly that should cover it. For more information on the netstring protocol see the official netstring protocol document.

 
Search for Posts
2013
 
2012
 
2011
 
2010
 
2009
 
2008
 
2007
 
2006
 
 
© 2008 Will McGugan.

A technoblog blog, design by Will McGugan