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.
MadChess 2.0 Development
Moderators: hgm, Rebel, chrisw
-
- Posts: 434
- Joined: Thu Apr 26, 2012 1:51 am
- Location: Oak Park, IL, USA
- Full name: Erik Madsen
MadChess 2.0 Development
My C# chess engine: https://www.madchess.net
-
- Posts: 7218
- Joined: Mon May 27, 2013 10:31 am
Re: MadChess 2.0 Development
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).
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).
-
- Posts: 454
- Joined: Mon Nov 01, 2010 6:55 am
- Full name: Ted Wong
Re: MadChess 2.0 Development
Thanks, Erik I'll follow your posts. Is there any reason that you don't want to switch to bitboard????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).
Henk, do you have any idea what you're talking about?
-
- Posts: 7218
- Joined: Mon May 27, 2013 10:31 am
Re: MadChess 2.0 Development
Maybe I might be wrong for evaluation is not executed for every move generated.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).
-
- Posts: 7218
- Joined: Mon May 27, 2013 10:31 am
Re: MadChess 2.0 Development
I thought Erik was using bit boards only. OK bye I'm out of this discussion, before making more mistakes and wrong assumptions.
-
- Posts: 434
- Joined: Thu Apr 26, 2012 1:51 am
- Location: Oak Park, IL, USA
- Full name: Erik Madsen
Re: MadChess 2.0 Development
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.kinderchocolate wrote:Thanks, Erik I'll follow your posts. Is there any reason that you don't want to switch to bitboard????
Henk, I use bit shift operations to encode moves and castling rights. But the board is represented as an int[64].I thought Erik was using bit boards only. OK bye I'm out of this discussion, before making more mistakes and wrong assumptions.
My C# chess engine: https://www.madchess.net
-
- Posts: 793
- Joined: Sun Aug 03, 2014 4:48 am
- Location: London, UK
Re: MadChess 2.0 Development
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.emadsen wrote: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.kinderchocolate wrote:Thanks, Erik I'll follow your posts. Is there any reason that you don't want to switch to bitboard????
Henk, I use bit shift operations to encode moves and castling rights. But the board is represented as an int[64].I thought Erik was using bit boards only. OK bye I'm out of this discussion, before making more mistakes and wrong assumptions.
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.
Disclosure: I work for DeepMind on the AlphaZero project, but everything I say here is personal opinion and does not reflect the views of DeepMind / Alphabet.
-
- Posts: 434
- Joined: Thu Apr 26, 2012 1:51 am
- Location: Oak Park, IL, USA
- Full name: Erik Madsen
Re: MadChess 2.0 Development
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 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.
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++.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'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.If you look at the Stockfish source code.
My C# chess engine: https://www.madchess.net
-
- Posts: 793
- Joined: Sun Aug 03, 2014 4:48 am
- Location: London, UK
Re: MadChess 2.0 Development
Well, Stockfish is one example of a very strong chess engine written in C++ .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.
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.
Disclosure: I work for DeepMind on the AlphaZero project, but everything I say here is personal opinion and does not reflect the views of DeepMind / Alphabet.
-
- Posts: 434
- Joined: Thu Apr 26, 2012 1:51 am
- Location: Oak Park, IL, USA
- Full name: Erik Madsen
Re: MadChess 2.0 Development
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.
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: https://www.madchess.net