Minimalism in chess programming

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.
maksimKorzh
Posts: 52
Joined: Sat Sep 08, 2018 3:37 pm
Location: Ukraine
Full name: Maksim Korzh
Contact:

Re: Minimalism in chess programming

Post by maksimKorzh » Fri Oct 05, 2018 7:43 am

I got that after daily applying trial and error method))) At the moment I'm trying to implement makemove/takeback routines separated from movegen to improve move ordering. Thank you for your help, Mr. Muller, you've left me alone at just the right moment :D I've been rewriting my micro-Max based movegen several times each time discovering something new I didn't see before. I have no idea whether I would ever be able to complete this engine or my fate is to maintain my previous one, nevertheless it's such an exiting journey :D Now I'm also trying single letter variables which is a pain on the one hand but makes me unexpectedly happy on the other. I really really appreciate your help Mr.Muller. I'm rereading all the posts you've written and probably would be able to understand them entirely one day :D

Sven
Posts: 3695
Joined: Thu May 15, 2008 7:57 pm
Location: Berlin, Germany
Full name: Sven Schüle
Contact:

Re: Minimalism in chess programming

Post by Sven » Fri Oct 05, 2018 3:48 pm

maksimKorzh wrote:
Fri Oct 05, 2018 7:43 am
Now I'm also trying single letter variables which is a pain on the one hand but makes me unexpectedly happy on the other.
I'd suggest not to write programs with single-letter variable names, type names etc. If you really want to keep up the goal of minimal source code size then write readable and working code first, and transform that development version into a read-only "minimal source code competition version" by string replacement whenever you want to, but apply further changes to the dev version only.

I think HGM did the same.
Sven Schüle (engine author: Jumbo, KnockOut, Surprise)

maksimKorzh
Posts: 52
Joined: Sat Sep 08, 2018 3:37 pm
Location: Ukraine
Full name: Maksim Korzh
Contact:

Re: Minimalism in chess programming

Post by maksimKorzh » Fri Oct 05, 2018 4:22 pm

hgm wrote:
Fri Oct 05, 2018 6:48 am
maksimKorzh wrote:
Sat Sep 29, 2018 12:45 pm
Mr. Muller, I've been researching my node calculating issue for several days and didn't find the solution so far, BUT now I know exactly where is the particular problem.

in this position:


my engine makes move d7d6 at depth 1, which puts king into check... and then starts to test opponent's(white) responses. It starts with bishop on b5. This is the move sequence being tested: b5a4(doesn't cause a beta cutoff due to the king wasn't capthured), b5c6(same), b5d7(same), b5e8(beta cutoff here, for the king capture has been detected). The problem is that the first three moves were counted as nodes for the condition if(score != -INF) failed, so it returned bestScore equals to 0 as common but even worth problem is that the move generation in this phantom line wasn't aborted. I've read at your site these words:
King captures never have to be executed. They lead to termination of the move generation altogether, because the previous move was apparently already an illegal one and we are working on a phantom branch of the search tree.
I assume this means that micro-Max aborts move generation in the case of king capture in such a way that previous illegal moves(king was in check) have not been researched recursively any further. So does it actually mean I have bug in my code?

Could you please tell me what would(or at least assumed to be) be the exact behavior of micro-Max in the position I've mentioned at depth 2? I really wonder.
The idea was that you would only count at d=1. The Bishop moves you describe should all occur at d=0, (reply to a d=1 move), and thus should not be counted. The d=0 level serves no other purpose than checking whether King capture is possible, so that the parent node can ignore moves that put the King in check.
Mr. Muller, I've finally passed the perft!!!! :D :D :D :D :D . Thank you very very much!!!! Everything you've written here as well as at your site made great use for me!!!! It took lots of time and effort to dive into the algorithms, but it was worth it. I didn't believe I'd succeed till today's evening. Here's the code https://github.com/maksimKorzh/Tighty/b ... r/Tighty.c A deep bow to you.

maksimKorzh
Posts: 52
Joined: Sat Sep 08, 2018 3:37 pm
Location: Ukraine
Full name: Maksim Korzh
Contact:

Re: Minimalism in chess programming

Post by maksimKorzh » Fri Oct 05, 2018 4:30 pm

Sven wrote:
Fri Oct 05, 2018 3:48 pm
maksimKorzh wrote:
Fri Oct 05, 2018 7:43 am
Now I'm also trying single letter variables which is a pain on the one hand but makes me unexpectedly happy on the other.
I'd suggest not to write programs with single-letter variable names, type names etc. If you really want to keep up the goal of minimal source code size then write readable and working code first, and transform that development version into a read-only "minimal source code competition version" by string replacement whenever you want to, but apply further changes to the dev version only.

I think HGM did the same.
HGM said it depends on your goals... My goals might seem pretty strange to most people, not only in chess programming. You're right from the practical perspective, but I've moved out of the 'dead point' exactly at the time of deleting my previous readable code github repo just a moment before to give up trying complete this movegen ever... This technical forum is definitely wrong plays to discuss such things, but I hope people would understand me - my goal is to fight my own weak sides. I'm a dumb, really, I hated math at school and never understood it, so for me programming is some kind of way to make my mind more clear as well as to develop a consciousness.

One letter variables are pain for sure, but it has some magic... You feel like a jeweler who handles a diamond, that's amazing feeling :)

maksimKorzh
Posts: 52
Joined: Sat Sep 08, 2018 3:37 pm
Location: Ukraine
Full name: Maksim Korzh
Contact:

Re: Minimalism in chess programming

Post by maksimKorzh » Wed Oct 10, 2018 2:42 pm

Mr. Muller, I have a move ordering related question.

In genmoves() I make() and unmake() each move to give it a score via eval(). Later in Search() I order the moves by score. The node count falls from 490000+ to 4500+ nodes which seems to be a good result. Does this technique allow to abandon mvv_lva scoring? (while mvv_lva doesn't actually affect the node count). Is it a good idea? May be I'm doing something wrong?(I have no gui connect protocol yet to check that out)

elcabesa
Posts: 732
Joined: Sun May 23, 2010 11:32 am
Contact:

Re: Minimalism in chess programming

Post by elcabesa » Wed Oct 10, 2018 4:19 pm

it's "teorically" a good idea, but "pratically" too slow. in the end the engine become too slow and loses strenght.

maksimKorzh
Posts: 52
Joined: Sat Sep 08, 2018 3:37 pm
Location: Ukraine
Full name: Maksim Korzh
Contact:

Re: Minimalism in chess programming

Post by maksimKorzh » Tue Oct 30, 2018 7:23 pm

Hi again, guys! I've started to learn NASM assembly and currently rewriting my engine in it! Many of you would probably consider such an idea to be completely weird because using modern C/C++ optimization flags would probably give as fast performance as assembly would give, but it was my childhood dream - to learn the assembly(back in that time of ZX SPECTRUM/Sinclair BASIC). I've currently implemented print board and parse FEN routines and it works just the same as it worked for me in C! Fantastic! This is how the work is going on... https://github.com/maksimKorzh/WTF/blob/master/WTF.asm
Please don't judge me strictly for I'm learning assembly only for the fourth day...
I'll appreciate your feedback even if it would be the same as the name of the current project of mine :D :D :D

P.S. Harm Geert Muller's opinion is especially important to me
mr. Muller, how do you like this? I've switched to assembly to deeper understand micro-Max's design and implementation concepts.

maksimKorzh
Posts: 52
Joined: Sat Sep 08, 2018 3:37 pm
Location: Ukraine
Full name: Maksim Korzh
Contact:

Re: Minimalism in chess programming

Post by maksimKorzh » Wed Nov 07, 2018 7:53 pm

As some sort of research and educational project I've implemented the move generator of micro-Max engine by Harm Geert Muller in NASM assembly in order to finally get complete understanding of what's going on inside there. I really doubt somebody is going to get interested, but nevertheless...
Here's the code:
https://github.com/maksimKorzh/MG

I also have a question to the community...

For these last three years I've learned to understand other people's code, I mean the ideas they use in their own engines, so the problem is I feel a bit like a monkey who only can use those ideas in own work instead of creating something unique. At this particular moment I can claim that I understand how does micro-Max work(after a couple of month research believe it or not!) or say how VICE by bluefever (TSCP successor) works as well. I've written a couple of ugly clones (you can find them in my github repo - https://github.com/maksimKorzh) of both - VICE and micro-Max, much weaker and less featured ugly clones... I'd like to find and go my own way, but can't find a source of inspiration. My goals are pretty vague which leads to unpredictable results at the end and abandoning projects on the half way. I need some sort of guide line... I want to keep maintaining my engine for years instead of couple of weeks and then give things up... So I'm asking those of you guys who is maintaining their engines for years... Could you please give me some guidance or source of inspiration, please help.

User avatar
cdani
Posts: 2065
Joined: Sat Jan 18, 2014 9:24 am
Location: Andorra
Contact:

Re: Minimalism in chess programming

Post by cdani » Wed Nov 07, 2018 10:47 pm

In Andscacs I tried to do most things in my own way, and once I understood about something better I tried to implement it in my own way also. For example the first move generator was scanning square after square until it found a piece or went out of the board, with a simple For. Only much later I tried to implement bitboards.
Another example is that I see games played badly by it and I try to understand what to improve, if I just try to tune manually a parameter or I add/change some code.
Of course I follow the development of other engines trying to find ideas. There is a lot to try.
Yes, is not 100% satisfying as doing everything for yourself, but is enough for me.

maksimKorzh
Posts: 52
Joined: Sat Sep 08, 2018 3:37 pm
Location: Ukraine
Full name: Maksim Korzh
Contact:

Re: Minimalism in chess programming

Post by maksimKorzh » Thu Nov 08, 2018 6:10 pm

cdani wrote:
Wed Nov 07, 2018 10:47 pm
In Andscacs I tried to do most things in my own way, and once I understood about something better I tried to implement it in my own way also. For example the first move generator was scanning square after square until it found a piece or went out of the board, with a simple For. Only much later I tried to implement bitboards.
Another example is that I see games played badly by it and I try to understand what to improve, if I just try to tune manually a parameter or I add/change some code.
Of course I follow the development of other engines trying to find ideas. There is a lot to try.
Yes, is not 100% satisfying as doing everything for yourself, but is enough for me.
Thanks a lot! That's the exact help I was looking for. Now I've come with a new idea where "Yes, is not 100% satisfying as doing everything for yourself, but is enough for me" is the solution.

Post Reply