Symbolic vs KingSlayer

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
hgm
Posts: 27819
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Underpromotion

Post by hgm »

mvk wrote:
hgm wrote:
mvk wrote:Very impressive, well done!
Well, no surprise there.
I find it impressive that Mini Rodent packs such a complete program in so little code while keeping the source a pleasure to read.
Note that I was commenting on the match result, not on the "well done" as your selective quoting suggests...
mar
Posts: 2559
Joined: Fri Nov 26, 2010 2:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: A better complexity metric

Post by mar »

sje wrote:

Code: Select all

Symbolic sje$ grep \; * | wc -l
   11421
Further:

Code: Select all

Symbolic sje$ grep goto * | wc -l
       0
Symbolic sje$ grep continue * | wc -l
       0
If you insist on counting statements, the number for SF is 3170 (4366 with Syzygy)

goto: there are cases where a simple goto means much less code since a goto-free transform is complicated.
I use continue (early bail outs in general) a lot because I hate excessive nesting, noodles of nested ifs going 10 levels deep make the code unreadable.
Dann Corbit
Posts: 12542
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: A better complexity metric

Post by Dann Corbit »

mar wrote:
sje wrote:

Code: Select all

Symbolic sje$ grep \; * | wc -l
   11421
Further:

Code: Select all

Symbolic sje$ grep goto * | wc -l
       0
Symbolic sje$ grep continue * | wc -l
       0
If you insist on counting statements, the number for SF is 3170 (4366 with Syzygy)

goto: there are cases where a simple goto means much less code since a goto-free transform is complicated.
I use continue (early bail outs in general) a lot because I hate excessive nesting, noodles of nested ifs going 10 levels deep make the code unreadable.
I am of the opinion that a goto statement should never be used, except when it is the best possible solution. This happens rarely, but it does happen.

IOW, more on the side of Knuth than Dijkstra.
mvk
Posts: 589
Joined: Tue Jun 04, 2013 10:15 pm

Re: A better complexity metric

Post by mvk »

mar wrote:goto: there are cases where a simple goto means much less code since a goto-free transform is complicated.
I use continue (early bail outs in general) a lot because I hate excessive nesting, noodles of nested ifs going 10 levels deep make the code unreadable.
Specifically for C, I found that a lot of coding style recommendations that are useful in projects where large groups of programmers must work together can become counterproductive in single-person projects such a chess engine. With "single-person project" I mean that a single person can grasp the entire code base without too much difficulty. (So Stockfish counts.)

Rookie v3 for example is compliant with the industrial standards I was used to as a professional software developer in a team of several 100s. But I realised that as a result, all of its code now looks like "work" and not like a cool hobby project. It has 32k lines of code (and 11k of comments). Not very large in industrial software, but to be honest, more than 10k is simply too much for just a chess engine. When you cross that point it helps to stop and contemplate.

This year I decided to experiment with different style elements in new projects, a dropped some of the dogmatic rules I was using for years. I found it can help to make a 10,000+ bloat projects into fun sub-5,000 line projects again.
[Account deleted]
Joost Buijs
Posts: 1564
Joined: Thu Jul 16, 2009 10:47 am
Location: Almere, The Netherlands

Re: A better complexity metric

Post by Joost Buijs »

Does it really matter how many lines of code a program has? I don't think so.

With operators like the conditional ternary operator in C and C++ you can pack several lines of code into one, but it doesn't make the program more readable.
I guess each programmer has is own style, what one person likes the other dislikes.
For instance I don't like the Stockfish code at all, while others are hailing it.
It can be nice to use some C++ constructs, but you must not overdo it.
mvk
Posts: 589
Joined: Tue Jun 04, 2013 10:15 pm

Re: A better complexity metric

Post by mvk »

Joost Buijs wrote:Does it really matter how many lines of code a program has? I don't think so.
Not by itself. But it is a rough indicator for cognitive load. Too dense and too "clever", and that goes up as well. And with well-chosen internal interfaces, the load can stay ok with a few more lines. But a chess engine has a fixed scope: there is only so much to say and everything else is additional load. I'm sure you have browsed through my Rookie v3 sources and know what I mean. I think that is a good example to "too big" already.
[Account deleted]
User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

Seven, plus or minus two

Post by sje »

Seven, plus or minus two, is reportedly the number of conceptual objects which can be held in a human's STM (Short Term Memory). Of course, a single conceptual object to an expert may be a dozen separate ones to a neophyte. The idea here is that there shouldn't be more than about seven different things happening at any point in the code's conceptual space.

The above is another good reason why global variables are generally a bad idea.

STM limitation is why a language like C++, when properly used, can be a very effective tool because its class mechanism supports encapsulation and abstraction, and this allows reduction of the conceptual space.

----

A third Symbolic vs KingSlayer match has started, and the score so far for Symbolic is WLD 8-13-3 (-73 elo). This lastest version of Symbolic features revised transposition table operation and pre-generation pruning. The program is searching more nodes but is getting better time to depth.
Joost Buijs
Posts: 1564
Joined: Thu Jul 16, 2009 10:47 am
Location: Almere, The Netherlands

Re: A better complexity metric

Post by Joost Buijs »

mvk wrote:
Joost Buijs wrote:Does it really matter how many lines of code a program has? I don't think so.
Not by itself. But it is a rough indicator for cognitive load. Too dense and too "clever", and that goes up as well. And with well-chosen internal interfaces, the load can stay ok with a few more lines. But a chess engine has a fixed scope: there is only so much to say and everything else is additional load. I'm sure you have browsed through my Rookie v3 sources and know what I mean. I think that is a good example to "too big" already.
At the time I tried to get Rookie running under Windows I looked at it of course.
It didn't struck me as being big, more like complicated and very reliant upon Linux specific things.

Without Nalimov probing code Nightmare is about 7000 lines, about 25% are empty lines, I like to have empty lines because it enhances readability.
So the actual code is about 5250 lines, and this includes all kinds of stuff that doesn't belong to the engine itself.

I have to agree that Rookie is rather big if it uses 10k lines of code.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Underpromotion

Post by bob »

mar wrote:
PK wrote:The goal is to beat Fruit 2.1 with less than 2500 lines of code.
Well, Stockfish is 5300 lines of code and beats anything out there.
How are you counting LOC? Counting ";" doesn't quite work.

if (c) {
}
else {
}
mar
Posts: 2559
Joined: Fri Nov 26, 2010 2:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: Underpromotion

Post by mar »

bob wrote: How are you counting LOC? Counting ";" doesn't quite work.

if (c) {
}
else {
}
I use my own tool which doesn't count separate punctuation as lines, therefore

Code: Select all

if (blah)
    stmt;
if (blah)
{
   stmt;
}
both count as 2 LOC

still there's no way to count reliably, I've seen many complicated attempts but they all fail of course

meaning that LOC is just an arbitrary metric that somehow correlates with code complexity