My Beginner’s Guide to Chess Programming

Discussion of anything and everything relating to chess playing software and machines.

Moderators: hgm, Rebel, chrisw

User avatar
Roland Chastain
Posts: 640
Joined: Sat Jun 08, 2013 10:07 am
Location: France
Full name: Roland Chastain

Re: My Beginner’s Guide to Chess Programming

Post by Roland Chastain »

lithander wrote: Sun Jan 24, 2021 2:32 am I had MinimalChess play 50 games against alouette64! Here are the results!
Thank you for trying Alouette.
lithander wrote: Sun Jan 24, 2021 2:32 am I picked DotNet Core specifically because it's supposed to be cross platform but I never used it before. Apparently you don't even need Linux to make a Linux build from Visual Studio. :shock: Then I downloaded my own zip from within an emulated Ubuntu and the only thing I had to do was to add the permission to execute the file. After that it responded to my 'uci' command as expected. Give it a try ;)
Yes, it works here too (Linux Mageia).

By the way, I notice that the line "id author ..." is missing. According to the protocol, this line is mandatory.
Qui trop embrasse mal étreint.
Gerd Isenberg
Posts: 2250
Joined: Wed Mar 08, 2006 8:47 pm
Location: Hattingen, Germany

Re: My Beginner’s Guide to Chess Programming

Post by Gerd Isenberg »

lithander wrote: Sun Jan 24, 2021 2:32 am Thanks for the many comments everyone!
Gerd Isenberg wrote: Sat Jan 23, 2021 10:55 pm You should take the next step to use alpha-beta instead of pure minimax. Iterative deepening as well.
I'm looking forward to trying that next!

But I'm considering to keep MinimalChess at it's current minimal scope and instead just make a 2nd repository with a different name where I don't have to worry about the goal of simplicity and how I would explain each bit of code in Youtube videos. ;)
Gerd Isenberg wrote: Sat Jan 23, 2021 10:55 pm Too many news - better use pre-allocated boards indexed by ply for copy-make.
The garbage collector of the .Net runtime is incredibly efficient and will reuse the same instances. But you made me curious. I just tried a view variants where I explicitly reused the same handful of boards (both with Array and Stack) and the best result I could get was 5.3s instead of 5.9s for a 5 ply search on a complicated mid game position. 10% faster searches isn't nothing.
But I'm sure in a non-managed language like e.g. C++ the difference would more noticeable.
Gerd Isenberg wrote: Sat Jan 23, 2021 10:55 pm Negamax does not imply multiplying with color all the time.
To quote CPW "In order for negaMax to work, your Static Evaluation function must return a score relative to the side to being evaluated" so the multiplying with color just happens somewhere else. But I shouldn't have called my implementation negamax, I guess. I'll remove the mention from the comments.

Thanks for your input! Each point has been very thought provoking!
One negate (unary minus) makes the relation min(a,b) == -max(-a,b) more explicit:

Code: Select all

int negaMax( int depth ) {
    if ( depth == 0 ) return evaluate(); // side to move relative
    int max = -oo;
    for ( all moves)  {
        score = -negaMax( depth - 1 );
        if( score > max )
            max = score;
    }
    return max;
}
User avatar
lithander
Posts: 881
Joined: Sun Dec 27, 2020 2:40 am
Location: Bremen, Germany
Full name: Thomas Jahn

Re: My Beginner’s Guide to Chess Programming

Post by lithander »

Gerd Isenberg wrote: Sat Jan 23, 2021 10:55 pm You should take the next step to use alpha-beta instead of pure minimax. Iterative deepening as well.
Took me a while to wrap my head around it but I'm convinced now that this would be not only the next logical step in development, but also isn't out of scope for a self-declared "minimal" engine.

My intuition that the next step in development should have been to focus on a better eval function was probably wrong, maybe even counter-productive, if the long term goal is to develop a strong engine. Instead it seems better to focus on a strong, bug-free search that can reach depths >10-12 first. Today I ran a few tournaments and reviewed games where the engine blundered against weaker engines and in each case a deeper search would have helped. The sacrifice of some simplicity seems to be a price worth paying in the face of these ugly blunders I saw! ;)

So based on all above comments so far I've collected these requirements before Minimal Chess is tournament ready:

Code: Select all

X  stable
X  win with huge material plus
X  correct move generator
X  play from arbitrary positions (fen and 'moves')
   support time controls, at least moves per session
   know repetition rules
   implement alpha beta pruning
   implement iterative deepening
   send "uci author"
   support "uci stop"
   send "uci info" to the GUI
Thanks for your help, everyone!
Minimal Chess (simple, open source, C#) - Youtube & Github
Leorik (competitive, in active development, C#) - Github & Lichess