cody powell dot com / projects / RubeChess

I like to play chess, but like a lot of people, I'm not very good. It's pretty frustrating to play almost any computer program because I end up getting trounced quickly. To get around this problem, I decided to write a program that plays chess like most of us do; I call it RubeChess (zip file with source here). RubeChess might just be the only chess program that an 8 year old could defeat.

RubeChess is written in the Ruby programming language. To run it, you'll need to install Ruby. Once that's done, just pull up a command prompt, type rubechess, and let the good times roll.

There are a few things to note here. First, we're using alpha-beta pruning to select our moves. I intentionally made the evaluation function stupid, but not too stupid, to give me a chance of beating it.

Second, even though we're only going a few levels deep in our tree of moves, it's still a little slow to generate a computer move (roughly 10 seconds on my laptop). I'm not sure if that's due to ruby's interpreted nature, or due to the extensive use of recursion in determining move validity.

Third, I wrote this to learn Ruby, so a lot of the code (especially in the beginning) is not a good example of The Ruby Way. I really liked the language, and I was halfway competent by the end of the project.

If you'd like to make improvements (and Lord knows this program needs it), feel free to do so. There are lots and lots of unit tests, so you'll know quickly whether you broke anything.

This code is released under the GNU Public License.