MadChess 2.0 Development

Discussion of chess software programming and technical issues.

Moderators: hgm, Harvey Williamson, bob

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
User avatar
emadsen
Posts: 164
Joined: Wed Apr 25, 2012 11:51 pm
Location: Naperville, IL, USA
Contact:

MadChess 2.0 Development

Post by emadsen » Wed Nov 12, 2014 6:53 am

I've been writing a new version of MadChess. For this 2.0 version, I'm writing code using procedural techniques rather than the object-oriented techniques I used in MadChess 1.x. I've reached a milestone- legal move generation.

I'm happy with the performance of the code, which is 4x faster than MadChess 1.x. Details at http://www.madchess.net/post/procedural-code.
Image
My C# chess engine: http://www.madchess.net

Henk
Posts: 5101
Joined: Mon May 27, 2013 8:31 am

Re: MadChess 2.0 Development

Post by Henk » Wed Nov 12, 2014 10:46 am

I think that if I would use bit boards only, evaluation would be slower. I also have separate lists for whitePawns .. blackKing etc where each list contains chessPieces that have a location.

So speeding up move generation doesn't help if evaluation gets much slower, but I might be wrong for my engine is not fast (actually slow).

kinderchocolate
Posts: 400
Joined: Mon Nov 01, 2010 5:55 am
Contact:

Re: MadChess 2.0 Development

Post by kinderchocolate » Wed Nov 12, 2014 11:05 am

Henk wrote:I think that if I would use bit boards only, evaluation would be slower. I also have separate lists for whitePawns .. blackKing etc where each list contains chessPieces that have a location.

So speeding up move generation doesn't help if evaluation gets much slower, but I might be wrong for my engine is not fast (actually slow).
Thanks, Erik I'll follow your posts. Is there any reason that you don't want to switch to bitboard????

Henk, do you have any idea what you're talking about?

Henk
Posts: 5101
Joined: Mon May 27, 2013 8:31 am

Re: MadChess 2.0 Development

Post by Henk » Wed Nov 12, 2014 11:08 am

Henk wrote:I think that if I would use bit boards only, evaluation would be slower. I also have separate lists for whitePawns .. blackKing etc where each list contains chessPieces that have a location.

So speeding up move generation doesn't help if evaluation gets much slower, but I might be wrong for my engine is not fast (actually slow).
Maybe I might be wrong for evaluation is not executed for every move generated.

Henk
Posts: 5101
Joined: Mon May 27, 2013 8:31 am

Re: MadChess 2.0 Development

Post by Henk » Wed Nov 12, 2014 11:10 am

I thought Erik was using bit boards only. OK bye I'm out of this discussion, before making more mistakes and wrong assumptions.

User avatar
emadsen
Posts: 164
Joined: Wed Apr 25, 2012 11:51 pm
Location: Naperville, IL, USA
Contact:

Re: MadChess 2.0 Development

Post by emadsen » Wed Nov 12, 2014 3:01 pm

kinderchocolate wrote:Thanks, Erik I'll follow your posts. Is there any reason that you don't want to switch to bitboard????
I like the simplicity of an array of squares. But mostly I enjoy the process of slowing increasing the sophistication of the code, from the direct and intelligible to the arcane. I'm very methodical as you can see. Perhaps I'll use bitboards for version 3.
I thought Erik was using bit boards only. OK bye I'm out of this discussion, before making more mistakes and wrong assumptions.
Henk, I use bit shift operations to encode moves and castling rights. But the board is represented as an int[64].
My C# chess engine: http://www.madchess.net

matthewlai
Posts: 736
Joined: Sun Aug 03, 2014 2:48 am
Location: London, UK
Contact:

Re: MadChess 2.0 Development

Post by matthewlai » Thu Nov 13, 2014 2:25 pm

emadsen wrote:
kinderchocolate wrote:Thanks, Erik I'll follow your posts. Is there any reason that you don't want to switch to bitboard????
I like the simplicity of an array of squares. But mostly I enjoy the process of slowing increasing the sophistication of the code, from the direct and intelligible to the arcane. I'm very methodical as you can see. Perhaps I'll use bitboards for version 3.
I thought Erik was using bit boards only. OK bye I'm out of this discussion, before making more mistakes and wrong assumptions.
Henk, I use bit shift operations to encode moves and castling rights. But the board is represented as an int[64].
That's what abstractions are for, so you can isolate complexity to small parts of the code to make it fast, yet present a simple interface for the rest of the program.

One way to do that is OOP, but in higher level languages like C# or Java, OOP probably does come with a performance penalty. That's why most object-oriented performance-critical programs (including chess engines) are written in C++. It's not as "clean" as C# or Java, but it allows you to do a lot of OOP with minimal/no performance penalty.

For example, if you look at the Stockfish source code. You'll see how simple it is. Most of the high level code reads like pseudo-code. Yet it's obviously extremely fast.
Author of Giraffe, an engine based on deep reinforcement learning. https://bitbucket.org/waterreaction/giraffe/overview

User avatar
emadsen
Posts: 164
Joined: Wed Apr 25, 2012 11:51 pm
Location: Naperville, IL, USA
Contact:

Re: MadChess 2.0 Development

Post by emadsen » Fri Nov 14, 2014 4:31 pm

That's what abstractions are for, so you can isolate complexity to small parts of the code to make it fast, yet present a simple interface for the rest of the program.
Yes, I know. I live in that world every day. I wrote MadChess 1.x to answer the question, if I write a chess engine using the business OO style code I write at work, how strong will it be? The answer is 2200 ELO, and more likely 2400 against human opposition.
That's why most object-oriented performance-critical programs (including chess engines) are written in C++. It's not as "clean" as C# or Java, but it allows you to do a lot of OOP with minimal/no performance penalty.
I agree. The main performance penalty coming from runtime-managed memory / garbage collection versus developer-allocated / deallocated memory. Though, I thought most strong engines are written in plain C, not C++.
If you look at the Stockfish source code.
I'm not interested in reading the Stockfish source code, though I understand and respect those who do. MadChess is done purely for my own intellectual satisfaction, so I'm quite content to build it ignorant of the state of the art. I am happy to reinvent the wheel- in fact that's the whole point since writing a chess engine is pretty much a solved problem at this point. Of course, if this was a professional project, I'd read the Stockfish source and incorporate as much as possible into the project. The mental effort of devising my own solutions, while intellectually satisfying, would be a waste of time to my employer.
My C# chess engine: http://www.madchess.net

matthewlai
Posts: 736
Joined: Sun Aug 03, 2014 2:48 am
Location: London, UK
Contact:

Re: MadChess 2.0 Development

Post by matthewlai » Fri Nov 14, 2014 4:57 pm

emadsen wrote: Yes, I know. I live in that world every day. I wrote MadChess 1.x to answer the question, if I write a chess engine using the business OO style code I write at work, how strong will it be? The answer is 2200 ELO, and more likely 2400 against human opposition.

I agree. The main performance penalty coming from runtime-managed memory / garbage collection versus developer-allocated / deallocated memory. Though, I thought most strong engines are written in plain C, not C++.

I'm not interested in reading the Stockfish source code, though I understand and respect those who do. MadChess is done purely for my own intellectual satisfaction, so I'm quite content to build it ignorant of the state of the art. I am happy to reinvent the wheel- in fact that's the whole point since writing a chess engine is pretty much a solved problem at this point. Of course, if this was a professional project, I'd read the Stockfish source and incorporate as much as possible into the project. The mental effort of devising my own solutions, while intellectually satisfying, would be a waste of time to my employer.
Well, Stockfish is one example of a very strong chess engine written in C++ :).

Going through the CEGT list (http://www.husvankempen.de/nunn/40_4_Ra ... liste.html) and skipping closed source engines -
Stockfish - C++
Gull - C++
Critter - C++
Strelka - no idea
Protector - C
Senpai - C++

I believe most/all of the top few closed source engines are C++ as well.

A few switched from C to C++ at some point, Crafty being a notable exception.

I have a lot of respect for Stockfish's authors not just because they made the strongest engine in the world, but also because they did it in extremely clean and easily-readable OOP C++ code. I would have enjoyed reading Stockfish code even if I had little interest in chess. It's living proof that clean OO style and performance aren't always against each other.

Though I feel that can only be said about C++, because C++'s implementation of OOP is very light, and in most cases incur no performance penalty at all.

Crafty's code is also very clean for a C program... but that's for a C program. Stockfish is still much easier to read.

I do respect that you are trying to be ignorant of the state of the art, but would highly recommend reading it if one day you lose interest in chess (or in being ignorant of the state of the art) :).

I wouldn't say chess is a solved problem. There are still many unexplored promising approaches. They may or may not be stronger, but are definitely very interesting. I am exploring a very interesting approach at the moment as my MSc thesis, but I can't say much about it at the moment, so that's for another time. I am basing it on Stockfish so I can focus my efforts on the novel parts, and not have to spend time reinventing wheels.
Author of Giraffe, an engine based on deep reinforcement learning. https://bitbucket.org/waterreaction/giraffe/overview

User avatar
emadsen
Posts: 164
Joined: Wed Apr 25, 2012 11:51 pm
Location: Naperville, IL, USA
Contact:

Re: MadChess 2.0 Development

Post by emadsen » Wed Nov 26, 2014 5:06 am

MadChess 2.0 can play a timed game of chess.

I've implemented an alpha / beta negamax search with aspiration windows and a capture / check evasion quiescence search. Evaluation is limited to material and middlegame piece square tables. No tapered evaluation, no passed pawn bonus, no piece mobility, no king safety, no reductions or pruning of moves, etc.

Rated about 1500 ELO.

Details at http://www.madchess.net/post/madchess-2-0-beta-build-20.
My C# chess engine: http://www.madchess.net

Post Reply