Xadrez - A p2p Chess Game written in Haskell

Motivation

Why to write another chess game implementation when there are so many (good) ones outside? This is certanly a good question. But when I tried to play chess with my friend, in all those possibilities, none of them satisfied us. We just wanted to play chess, not to read all the options of a big manpage or to start the X server just to play a game.

We thought it would be simpler just to write a simple and light implementation of chess than adapting ourselfs to some options-full X program. So we did! Haskell was the language of choice, it's a very elegant language and we wanted to learn more about it. Some friends started using our chess for its simplicity and then we thought it would be a good idea to make it public.

Actual State

The program implements almost every chess functions, so that you can play a game regularly. The Check and Mate check's are not yet full writen, but some part of the code is already done. The main function does not have access to this code, so that it doesn't change the program behaviour.

Language

It's written in Haskell, a functional language that can make powerfull things in very few lines of code. The choice was because of it simplicity and because it's very easy to read and mantain. The program is almost fully functional, only with the main functions that are IO related using Monads. It requires the GHC compiler to work.

Download

You can get Xadrez from Savannah. The nightly CVS snapshot is available, and you can get the cvs with anonymous login.

Build

Extract the .tar.gz file with:
$ tar zxf xadrez-haskell-sources.tar.gz
Then change to the dir:
$ cd xadrez-haskell/
And build it:
$ make
To run:
$ src/xadrez

Install

To install it (after make):
$ su
# make install

Run

If you have installed the program then simply run:
$ xadrez
If you haven't installed:
$ src/xadrez

Cygwin

If you are running Cygwin, it's a good choice to compile it with the binary output to xadrez.exe instead of just xadrez. To do it build with:
$ make BIN=xadrez.exe
And install it with:
# make install BIN=xadrez.exe

Options

-s, --server
Start xadrez as server.
-p PORT, --port PORT
Change the port used by xadrez. By default it uses 13033.
-v, --version
Display version information.
-h, --help
Display a help message.

Examples

xadrez
xadrez -s
xadrez -p 1010
xadrez -p 1010 -s
xadrez --version
xadrez --help

Playing

If you start Xadrez as server you'll have to wait for the other player's connection, otherwise you must type the sever's IP. After that the game starts. When it's the other player's turn you just wait for him to make his move. When the turn is your's you should use one of the following commands in the prompt to make your move:

(a-h)(1-8) (a-h)(1-8)
Move piece in the first coordinate to the square in the second coordinate.
(! | q)
Leave the game.

Contact


Last modified: Sun Apr 24 15:33:27 BRT 2005