new project: CLI for chess tournaments

Discussion of chess software programming and technical issues.

Moderator: Ras

lucasart
Posts: 3243
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

new project: CLI for chess tournaments

Post by lucasart »

I'm trying to do something like cutechess-cli. For the moment, it's very limited, but some of the basics are there (can play a single game, UCI only, POSIX only).

If you want to have a look:

download source and compile

Code: Select all

$ git clone https://github.com/lucasart/chess
$ cd ./chess
$ make
use with two parameters: engine_white engine_black. will play a single game with time control hardcoded at 100ms/move for now. Sample run:

Code: Select all

lucas@lucas-desktop:~/Chess/chess$ ./chess ../Engines/discocheck_3.7.1 ../Engines/fruit_2.1 
e4	Nc6	
Nf3	Nf6	
e5	Nd5	
d4	e6	
Bc4	Bb4+	
Bd2	OO	
OO	d6	
c3	Ba5	
Na3	dxe5	
dxe5	Bb6	
Qc2	Qd7	
Rad1	a6	
Bd3	g6	
Bh6	Rd8	
Bg5	Re8	
Be4	Rf8	
Qb1	Qe8	
Bh6	Nce7	
Nc2	f5	
Bxd5	exd5	
Bxf8	Qxf8	
Rfe1	Qh6	
e6	g5	
Ncd4	g4	
Nxf5	Nxf5	
Qxf5	gxf3	
Qf7+	Kh8	
Qe8+	Kg7	
Qe7+	Kh8	
Rxd5	Bxe6	
Rxe6	Qc1+	
Re1	Bxf2+	
Kxf2	Qxb2+	
Kxf3	Qxc3+	
Re3	Qc6	
Kf2	Qc2+	
Re2	Qc6	
Rd7	Qg6	
Rd8+	Rxd8	
Qxd8+	Kg7	
Re7+	Qf7+	
Rxf7+	Kxf7	
Qxc7+	Kg6	
Qxb7	a5	
Qa6+	Kf7	
Qxa5	Ke6	
Qb6+	Ke7	
Qc5+	Ke6	
a4	Kd7	
a5	h6	
a6	h5	
a7	Ke6	
a8Q	Kf6	
Qaf8+	Ke6	
Qcf5+	White wins by check mate
If anyone is interested in helping to develop it, feel free to join! People with experience in multi-threading are most welcome, as I have none myself.
Theory and practice sometimes clash. And when that happens, theory loses. Every single time.
User avatar
ilari
Posts: 750
Joined: Mon Mar 27, 2006 7:45 pm
Location: Finland

Re: new project: CLI for chess tournaments

Post by ilari »

lucasart wrote:I'm trying to do something like cutechess-cli. For the moment, it's very limited, but some of the basics are there (can play a single game, UCI only, POSIX only).
I'm already following your project at Github and I wish you success. I remember when cutechess-cli was at that stage - you have quite a lot of work ahead of you.
Michel
Posts: 2292
Joined: Mon Sep 29, 2008 1:50 am

Re: new project: CLI for chess tournaments

Post by Michel »

The makefile did not work for me.

I replaced the compile command by

g++ *.cc -o ./chess -DNDEBUG -Wall -std=gnu++0x -g -O2

which worked.

The executable seems to run fine.
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: new project: CLI for chess tournaments

Post by Evert »

lucasart wrote: If anyone is interested in helping to develop it, feel free to join! People with experience in multi-threading are most welcome, as I have none myself.
I won't, but I will confess that I started a command-line based match/referee program based on my variant engine Sjaak (provisionally called Sjef) literally the other day. Its main purpose (for me) is to have a GUI-less referee program that I can use to play variant matches, something cutechess-cli isn't really suitable for.

It currently loads up the engines and initialises them, actually parsing the engine responses is next on the list, followed by being able to play an actual game.

I suspect it won't compile on Windows though, since I used fork() to split off the engine processes. I could switch to threads (I've used pthreads in the past), but I find fork() to be much easier (if a bit dirty) to be honest...
Michel
Posts: 2292
Joined: Mon Sep 29, 2008 1:50 am

Re: new project: CLI for chess tournaments

Post by Michel »

but I find fork() to be much easier (if a bit dirty) to be honest...
fork is not dirty at all. It is a very clean way to start up processes.
rreagan
Posts: 102
Joined: Sun Sep 09, 2007 6:32 am

Re: new project: CLI for chess tournaments

Post by rreagan »

lucasart wrote:I'm trying to do something like cutechess-cli. For the moment, it's very limited, but some of the basics are there (can play a single game, UCI only, POSIX only).
Out of curiosity, is it just your own hobby project, or do you hope to fill a need that cutechess-cli doesn't fill?
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: new project: CLI for chess tournaments

Post by Evert »

Michel wrote:fork is not dirty at all. It is a very clean way to start up processes.
Don't get me wrong: I love fork and use it quite often. I probably prefer it to messing around with pthreads. However, I do feel that the idea of specifying a subroutine that you want to start parallel execution from is conceptually a bit cleaner than splitting the execution at the current line in the code.
Michel
Posts: 2292
Joined: Mon Sep 29, 2008 1:50 am

Re: new project: CLI for chess tournaments

Post by Michel »

However, I do feel that the idea of specifying a subroutine that you want to start parallel execution from is conceptually a bit cleaner than splitting the execution at the current line in the code.
I always have difficulty remembering the signature of such a function and how to pass data to it (usually mucking about with a (void *) pointer)... No such problem with fork()...
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: new project: CLI for chess tournaments

Post by Evert »

Michel wrote: I always have difficulty remembering the signature of such a function and how to pass data to it (usually mucking about with a (void *) pointer)... No such problem with fork()...
Same here.
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: new project: CLI for chess tournaments

Post by Evert »

So far Sjef is coming along quite nicely:

Code: Select all

eglebbk@morgaine $./sjef -fcp xsjaak -scp xleo -mg 4 -variant spartan -tc 40/0:05+0
Starting xsjaak
Starting xleo
Intialising program 1...done
Intialising program 2...done
Time control: 40/0:05+0
Starting variant 'spartan' (Sjaak 478M - Leonidas 50) game 1 of 4
0-1 (Black mates)
Starting variant 'spartan' (Leonidas 50 - Sjaak 478M) game 2 of 4
1/2-1/2
Starting variant 'spartan' (Sjaak 478M - Leonidas 50) game 3 of 4
0-1 (Black mates)
Starting variant 'spartan' (Leonidas 50 - Sjaak 478M) game 4 of 4
0-1 (Black mates)
Result: 1 - 1 - 2 (1.5-2.5)
eglebbk@morgaine $
The main thing that's missing is that the resulting games are not written to a .pgn file. Shouldn't be too hard to fix though. I also don't know how robust Sjef is with respect to misbehaving engines (not very, I suspect, since I didn't put a whole lot of effort in that). It currently aborts the match if one of the two engines crashes, while it should probably restart the engine instead. I also haven't tried ponder on matches.