A new chess engine : m8 (comming not so soon)

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

mathmoi
Posts: 286
Joined: Mon Mar 13, 2006 5:23 pm
Location: Québec

A new chess engine : m8 (comming not so soon)

Post by mathmoi »

For more than a decade now, I’ve been programming chess engines as a hoby on and off. However I’ve not seriously worked on my current engine, MatMoi VII for almost two years now. But I’m thinking about comming back to computer chess programming.

If I do pick up chess programming again I will start over wrtiting an 8th iteration of my engine. I think it will be more enjoyable for me to work on a new code base than to work again on MatMoi with its flaws. For the last couples of weeks I’ve been thinking about what I could do differently in my next engine, m8 (read mate). I’ve isolated the following designs goals/ideas/principles that I will try to follow:

1. KISS

Keep it simple stupid. This is a principle I always try to follow while writing code, but I’ll make a special effeort to keep it in mind while writing m8. A chess engine usually contains lots of micro-optimizations that make the code less readable. In m8 I’ll make sure that each of those is really worth the increase in complexity.

2. Unit-testing and Assertions

I don’t plan on doing TDD or have 100% test coverage, but any test that can be automated will be. I also plan on heavily using assert throughout the code.

3. Testing

For a couples of years now the trend in computer chess programming is on testing everything with thousands of games. With m8 I plan on doing this early and also plan on building multiples tests utilities. There is three types of test I want to be able to perform early :

Positions tests suits (EPD files);
Rating tests where m8 plays hundreds or thousands of games against a couples of opponent in order to measure it’s strength;
Rapid self play tests. Theses are less common. I want m8 to be able to play really fast self play games using differents sets of parameters. This functionality could be use to tests differents evaluation function against each others for example.
4. Parametrization

Everything that can be parameterized should be. Especially search and evaluation parameter. Also the user should be allowed to set theses parameter in a configuration file, on the command line or in the command line interface. The idea is to make it as easy as possible to test differents values for any parameters of the engine.

5. Open formats

If possible any files read or written by m8 should be in an open format. Things like the opening book should not be in binary format if possible (I say if possible because I’m not sure it would be efficient to have a plain text opening book). An opening book in text format can be read and modified by a human. If text format is not an option an open binary format should be used (Think SQLite).

6. Fisher Random Chess

I’ll implement FRC from the start. It’s not too hard to implement and since there is not many FRC engine it could make m8 more appealing.

7. YBWC

I’ll try to make m8 my first multiprocessor engine.

8. Blog

I’ll try to keep a journal of my ideas and experiments and if I think some of theses could be useful or interesting to others I’ll try to blog about it.



Do you guys have any advice or comments for someone who is about to start from scratch again?

PS. I've posted this an article on my blog : http://mathieupage.com/?p=81
User avatar
Graham Banks
Posts: 41416
Joined: Sun Feb 26, 2006 10:52 am
Location: Auckland, NZ

Re: A new chess engine : m8 (comming not so soon)

Post by Graham Banks »

mathmoi wrote:For more than a decade now, I’ve been programming chess engines as a hoby on and off. However I’ve not seriously worked on my current engine, MatMoi VII for almost two years now. But I’m thinking about comming back to computer chess programming.

If I do pick up chess programming again I will start over wrtiting an 8th iteration of my engine. I think it will be more enjoyable for me to work on a new code base than to work again on MatMoi with its flaws...
Great news! :)
gbanksnz at gmail.com
Ferdy
Posts: 4833
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: A new chess engine : m8 (comming not so soon)

Post by Ferdy »

Perhaps you may try chess variant, say capablanca, 8 rows x 10 columns. Two pieces each are added in each side, one piece is a combination of knight and rook the other piece is a combination of knight and bishop. It is fun and interesting to explore the possibilities of these two new pieces over the expanded board.
mar
Posts: 2554
Joined: Fri Nov 26, 2010 2:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: A new chess engine : m8 (comming not so soon)

Post by mar »

I'm pretty sure you meant
mathmoi wrote:7. Lazy smp
:wink:
It scales above 16 cores and works even at ultra-fast TC (1" per game).
YBWC already contradicts point 1 (lazy smp can be implemented and debugged in two weeks or perhaps even less).
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: A new chess engine : m8 (comming not so soon)

Post by Evert »

Ferdy wrote:Perhaps you may try chess variant, say capablanca, 8 rows x 10 columns. Two pieces each are added in each side, one piece is a combination of knight and rook the other piece is a combination of knight and bishop. It is fun and interesting to explore the possibilities of these two new pieces over the expanded board.
I can only add my support for this suggestion. If you want to stick with 8x8, consider Seirawan Chess: it adds the same two pieces as Capablanca chess, and regular chess is just a subset Seirawan Chess anyway.

EDIT: think of it this way: another chess engine is just that, they're a dime a dozen. Another chess variant engine is something special. There may be fewer people interested in chess variant engines, but because there are so few of them out there, people who are interested will be interested in yours.
Modern Times
Posts: 3546
Joined: Thu Jun 07, 2012 11:02 pm

Re: A new chess engine : m8 (comming not so soon)

Post by Modern Times »

mathmoi wrote: 6. Fisher Random Chess

I’ll implement FRC from the start. It’s not too hard to implement and since there is not many FRC engine it could make m8 more appealing.
Excellent idea :)
mathmoi
Posts: 286
Joined: Mon Mar 13, 2006 5:23 pm
Location: Québec

Re: A new chess engine : m8 (comming not so soon)

Post by mathmoi »

Ferdy wrote:Perhaps you may try chess variant, say capablanca, 8 rows x 10 columns. Two pieces each are added in each side, one piece is a combination of knight and rook the other piece is a combination of knight and bishop. It is fun and interesting to explore the possibilities of these two new pieces over the expanded board.
I'd like to implements other variants beside FRC but m8 will be a bitboard engine and I don't think there is an easy way to implement a 8 x 10 variant as a bitboard engine. Is there?
mathmoi
Posts: 286
Joined: Mon Mar 13, 2006 5:23 pm
Location: Québec

Re: A new chess engine : m8 (comming not so soon)

Post by mathmoi »

mar wrote:I'm pretty sure you meant
mathmoi wrote:7. Lazy smp
:wink:
It scales above 16 cores and works even at ultra-fast TC (1" per game).
YBWC already contradicts point 1 (lazy smp can be implemented and debugged in two weeks or perhaps even less).
Isn't lazy SMP the technique that use the TT as a communication device between threads that search the same tree? My understanding was that it gave little speedup passed 2 CPU. Am I missing something?

You are right, YBWC is not really KISS compliant. I was thinking about it because it seems to be not too complicated (compared to DTS) and still giving interesting results. This being said, before I implement SMP I will need to do some research to make sure I choose a good approach.
mathmoi
Posts: 286
Joined: Mon Mar 13, 2006 5:23 pm
Location: Québec

Re: A new chess engine : m8 (comming not so soon)

Post by mathmoi »

Evert wrote:
Ferdy wrote:Perhaps you may try chess variant, say capablanca, 8 rows x 10 columns. Two pieces each are added in each side, one piece is a combination of knight and rook the other piece is a combination of knight and bishop. It is fun and interesting to explore the possibilities of these two new pieces over the expanded board.
I can only add my support for this suggestion. If you want to stick with 8x8, consider Seirawan Chess: it adds the same two pieces as Capablanca chess, and regular chess is just a subset Seirawan Chess anyway.

EDIT: think of it this way: another chess engine is just that, they're a dime a dozen. Another chess variant engine is something special. There may be fewer people interested in chess variant engines, but because there are so few of them out there, people who are interested will be interested in yours.
Hi Evert,

I'll look into this. As I said, I'm interested in implementing search variant, but I am probably limited to 8 x 8 variants since I want to use bitboards.
User avatar
hgm
Posts: 27789
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: A new chess engine : m8 (comming not so soon)

Post by hgm »

There are zillions of variants on 8x8 boards. E.g. Seirawan Chess, Makruk, Spartan Chess, Knightmate, Mighty-Lion Chess, all flavors of Chess with Different Armies, King of the Hill, Team Mate Chess...
mathmoi wrote:Things like the opening book should not be in binary format if possible (I say if possible because I’m not sure it would be efficient to have a plain text opening book). An opening book in text format can be read and modified by a human. If text format is not an option an open binary format should be used (Think SQLite).
Actually Polyglot books (an open binary format) are much easier to read and modify by a human than plain text. Because you can use a Chess GUI like WinBoard to edit them, so that you can enter the new moves by playing them, rather than typing them, they are automatically checked for legality, you can walk through the book by just clicking in the list of moves from the current position, etc.