McBrain 9.0 with Smarter Tactical Setting

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

Moderators: hgm, Rebel, chrisw

User avatar
Ovyron
Posts: 4556
Joined: Tue Jul 03, 2007 4:30 am

McBrain 9.0 with Smarter Tactical Setting

Post by Ovyron »

Apparently I'm not the only one interested in this, and since this is the engine I'm currently using as my main engine, over things like Komodo, Houdini or Stockfish dev, I think it's worthy of release.

This is a McBrain version with a Tactical setting meant to be used by correspondence chess players that need an engine that will find the best moves ASAP, and for certain scenarios I'll explain below, this will find better moves faster than default McBrain, and will look for alternative moves faster than any other engine. It's mainly useful for the interacting chess player, that jumps from one position to another, extends branches, refutes variations, and comes back to the root to look for alternatives if everything else has been refuted.

If you want an engine that finds best moves in puzzles, quizes, test suites, or you will leave the engine analyzing for multiple hours in a position without interacting with it, this version is not for you and you're better using default McBrain.

Please note, this is exactly McBrain 9 with just one line of code removed, so I'm not taking any credit for it. Credit goes to M. Byrne, the people that provided patches for his version, and all Stockfish 9 developers. Basically McBrain is already designed for analysis and finding best moves faster, what I'll be explaining is how to take advantage from the Tactical setting so that you can interact with the engine and find the best variation at the highest depth ASAP.

http://www.mediafire.com/file/amwhgubdyrhewjt/src.zip

That's the modified source. It also includes 2 bat files to compile it for basic x64 architectures. You run mak.bat, rename the engine "McBrain-91.exe" after it's done, and run cle.bat to get rid of useless files. This is done so cle.bat doesn't delete the engine, but no "McBrain 9.1" actually exists.

The Procedure

I was contacted by PM by someone that wanted me to explain what was the deal with this improved Tactical setting, so here goes.

Please note that out of the box, after you set something like "Tactical=2" on engine options, McBrain's output will actually be rather confusing.

But fear not, here I'm going to use Tactical=2 as an example, which will be identical to MultiPV=4, for other Tactical settings just change the powers of 2. I recommend Tactical=2 for an analysis time per position of 1 minute in average, or for an analysis depth of 28. If you analyze for 30 seconds, use Tactical=1. For 2 minutes use Tactical=3, for 4 minutes use Tactical 4, and so on. For Depth 27 use Tactical=1, for Depth 29 use Tactical=3, for Depth 30 use Tactical=4, and so on.

Use the Tactical Setting on Play Mode

So here's the advantage of using the Tactical setting over MultiPV... you don't need to make the moves on the board! Just set your depth or thinking time and ask McBrain for a move, then McBrain will show you the move and its score, plus the scores of another 3 moves.

Please note Stockfish will order the moves backwards. Usually, on single PV, Stockfish will show better moves at the bottom of the analysis, and the best one will be at the very bottom, but here, Stockfish will be showing at the very bottom the last move analyzed... which will be the 4th best! The 3rd best will be above it, the 2nd best will be above it, and the very best (which was moved on the board) will be at the top.

You should only pay attention to the last 4 output lines and ignore the rest. Interestingly, I still use Shredder Classic 3's "Continuous Display" option that makes MultiPV behave like this for all engines, because it was removed in some later version of Shredder Classic.

Try to refute McBrain's lines

I assume that you have some way to store your analysis somewhere, in a tree, or a graph. What you want to do is to give McBrain one side of the board, make it play with the Tactical setting, and record the 4 best moves it outputs to the file.

Now, you should have an "adversary" engine loaded in a different GUI instance, and this adversary will be trying to refute the lines that McBrain outputs.

Right after McBrain makes a move, make this move to the adversary engine, and while it's thinking on a move, record the best McBrain moves to your tree.

An example

Suppose the position is quiet, there's no actual Tactical shot to find, but you still want to find the most promising continuation.

After you make McBrain play a move, it outputs:

28/43 0:59 0.24 20.A
28/40 0:59 0.22 20.B
28/24 0:59 0.19 20.C
28/49 0:59 0.18 20.D

The only things that matter are the moves and their scores, so I'll be ommitting the rest below.

You play move A to the adversary engine, and while it's thinking you record the scores of the moves.

Let's say Houdini 6 Tactical=1 Contempt=2 is the adversary engine, it plays...

-0.09 20...A

Huh, -0.09 actually means 0.00 but Houdini thinks Black is the one that could gain the edge. The position is interesting because if it's seen from the distance, it means that if McBrain is wrong Houdini will be able to refute its variations, the user might be better choosing one that both Houdini and McBrain like. Otherwise, we want to know what Houdini is seeing that McBrain isn't...

Record that on your tree, now we play 20...A on the board for McBrain to look at...

0.26 21.A
0.23 21.B
0.00 21.C
-0.01 21.D

Still looking good. Play 21.A to Houdini, and record all 4 moves' scores.

Houdini:

-0.09 21...A

Houdini still doesn't see White's advantage...

Back to McBrain...

0.32 22.A
0.00 22.B
0.00 22.C
0.00 22.D

Record those...

Houdini:

0.10 22...A

Aha, this refutes Houdini's variation. What the user does now depends on the human element, but let's say she jumps back a move, and uses "go searchmoves" to ask for an alternative to Houdini's 21...A:

-0.09 21...B

Play it against McBrain...

0.00 22.A
0.00 22.B
-0.08 22.C
-0.24 22.D

Ah! McBrain's mainline is refuted! It was missing this possibility!

This refutes 21.A - that position now looks like this:

0.00 21.A B 22.A
0.23 21.B
0.00 21.C
-0.01 21.D

We play 21.B against Houdini...

0.02 21...A

Houdini now likes white a bit better. I'll go back a move and see if Houdini has another idea (20...A is excluded)

0.20 20...B

No, it thinks 20...A is much better, so play 21...A against McBrain.

0.17 22.A
0.16 22.B
0.10 22.C
-0.00 22.D

Oh, look! This entire line by McBrain falls down, as it now likes it worse than 20.B, 20.C or 20.D at the root...

Position from a moves ago looks like this:

0.00 21.A B 22.A
0.17 21.B A 22.A
0.00 21.C
-0.01 21.D

Root position looks like this:

0.17 20.A A 21.B A 22.A
0.22 20.B
0.19 20.C
0.18 20.D

So, let's play 20.B to Houdini...

-0.60 20...A

Wow! Houdini thinks sacking some Knight is best and its score jumps, let's see what McBrain has to say...

-0.08 21.A
-0.30 21.B
-0.60 21.C
-0.94 21.D

Aha, McBrain was reducing this variation, so 20.B is actually a poor movr for white...

Root looks like this:

0.17 20.A A 21.B A 22.A
-0.08 20.B A
0.19 20.C
0.18 20.D

Play 20.C against Houdini...

0.20 20...A

Okay, so now both McBrain and Houdini agree 20.C is best. The user might want to extend C to see if it holds, change to some other adversary engine, see if McBrain also likes it from the black side, check out 20.D, or maybe use human input and see if some of the future moves proposed work at the root, etc.

Why is it "Smarter"?

A reason for which an user using methods like this might want to use this version instead of default it's when something like this appears on the radar...

-0.25 25...A
-0.36 25...B
-0.40 25...C
-2.35 25...D

Here, only 3 moves are playable, but Tactical is wasting time analyzing the 4th one. The user can save time by using "go searchmoves" to only analyze A, B and C, and Mc Brain will show the scores of all 3 moves, unlike default that would only show a score for the best of these 3 moves.

In a scenario like:

-0.09 35...A
-1.36 35...B
-2.40 35...C
-6.38 35...D

A user with default Tactical setting would waste a whole move to have the engine give a score to A, while the one with this version can move 35...A already to the adversary engine (because the move is forced).

I have refuted everything!

So, suppose in the above example 20.C and 20.D fall to a score <=0.17, what if there's a 5th move with a score => 0.18? Well, all the user needs to do is using "go searchmoves" to exclude 20.A, 20.B, 20.C and 20.D from analysis, and this McBrain will output scores for 20.E, 20.F, 20.G and 20.H.

The Human Element

And a final advantage of Smarter Tactical Setting over default is this scenario:

0.20 40.A
0.20 40.B
0.20 40.C
0.20 40.D

Default would only show A's score and the user would have no idea that the other moves are as good. With this one the human can use its chess knowledge of the position to actually play the most interesting move that they want to examine.

What's the difference between this and setting my GUI to play mode with some MultiPV setting?

There's no difference, but many GUIs for analysis don't support that (they switch to SinglePV in play mode), nor do they allow to use "go searchmoves" with MultiPV (again, it goes back to SinglePV) so hacking the Tactical setting is the solution.

In the end, this Tactical setting is as fast as the default one for finding the best moves, but when McBrain still misses the best move and the user has to refute the top choices to find it, the Smarter Tactical Setting will have given evaluations to alternative moves to get up to speed for free.
Your beliefs create your reality, so be careful what you wish for.
Rodolfo Leoni
Posts: 545
Joined: Tue Jun 06, 2017 4:49 pm
Location: Italy

Re: McBrain 9.0 with Smarter Tactical Setting

Post by Rodolfo Leoni »

Looks brilliant. :wink:

Maybe Mike Byrne will consider the idea to include your solution into next release of McBrain. Besides, I still hope he'll include the persistent hash and the load/save hash code by Daniel Jose as an option. As it only works with infinite analysis mode it wouldn't affect playing strenght, but it's a great help for analyses. Let us see...
F.S.I. Chess Teacher
User avatar
Ovyron
Posts: 4556
Joined: Tue Jul 03, 2007 4:30 am

Re: McBrain 9.0 with Smarter Tactical Setting

Post by Ovyron »

I suggest a checkbox "Show Alternative Tactical Lines" that would make the engine behave like this. Really, the only reason Tactical doesn't behave like this by defaults is because new users would get confused (because the last move analyzed looks like the best in SinglePV).

Perhaps what we need is more code changes so that the engine keeps the best move at the very bottom of the analysis like with Tactical Off.

Now, what I'd really want is more frequent updates since Michael said next McBrain will be released with Stockfish 10 :cry:
Your beliefs create your reality, so be careful what you wish for.
maxdeg
Posts: 229
Joined: Thu Mar 10, 2016 6:17 pm
Location: Canada

Re: McBrain 9.0 with Smarter Tactical Setting

Post by maxdeg »

+1 .. +1 .. and thanks again .. :D
Leo
Posts: 1078
Joined: Fri Sep 16, 2016 6:55 pm
Location: USA/Minnesota
Full name: Leo Anger

Re: McBrain 9.0 with Smarter Tactical Setting

Post by Leo »

How are your games against Rodolfo going? Your both undefeated right?
Advanced Micro Devices fan.
User avatar
Ovyron
Posts: 4556
Joined: Tue Jul 03, 2007 4:30 am

Re: McBrain 9.0 with Smarter Tactical Setting

Post by Ovyron »

Leo wrote:How are your games against Rodolfo going? Your both undefeated right?
Nah, I've been defeated many times over the years, I'm just undefeated at FICGS and the LSS. And I haven't been defeated since 2014.

We're still on the opening phase in both games, but he can tell you that I'm low on time in both, with less than 11 days remaining, but I think I'll manage (famous last words! :lol: )
Your beliefs create your reality, so be careful what you wish for.
Rodolfo Leoni
Posts: 545
Joined: Tue Jun 06, 2017 4:49 pm
Location: Italy

Re: McBrain 9.0 with Smarter Tactical Setting

Post by Rodolfo Leoni »

Ovyron wrote:
Leo wrote:How are your games against Rodolfo going? Your both undefeated right?
Nah, I've been defeated many times over the years, I'm just undefeated at FICGS and the LSS. And I haven't been defeated since 2014.

We're still on the opening phase in both games, but he can tell you that I'm low on time in both, with less than 11 days remaining, but I think I'll manage (famous last words! :lol: )
Yes, still in book. 16 moves per game so far and positions are quite even. No time problems for me, 40 days per game.

@Ulysses: I just played 16. ..Qe8 :P
F.S.I. Chess Teacher
User avatar
Ovyron
Posts: 4556
Joined: Tue Jul 03, 2007 4:30 am

Re: McBrain 9.0 with Smarter Tactical Setting

Post by Ovyron »

Rodolfo Leoni wrote:@Ulysses: I just played 16. ..Qe8 :P
Ah, but I still have 11 days in that game... it can wait while I attempt to save all my other games with 10, 9 or even 8 days remaining! :lol:
Your beliefs create your reality, so be careful what you wish for.
Rodolfo Leoni
Posts: 545
Joined: Tue Jun 06, 2017 4:49 pm
Location: Italy

Re: McBrain 9.0 with Smarter Tactical Setting

Post by Rodolfo Leoni »

Ovyron wrote:
Rodolfo Leoni wrote:@Ulysses: I just played 16. ..Qe8 :P
Ah, but I still have 11 days in that game... it can wait while I attempt to save all my other games with 10, 9 or even 8 days remaining! :lol:
It happened once that an opponent (Roman Usmanoff, you can look at that game if you want) waited until he had 1 day, then he moved. He played the whole game in zeitnot and when his position got hopeless he lost on time. :lol:

But 10 days aren't a problem.
F.S.I. Chess Teacher
User avatar
Ovyron
Posts: 4556
Joined: Tue Jul 03, 2007 4:30 am

Re: McBrain 9.0 with Smarter Tactical Setting

Post by Ovyron »

Rodolfo Leoni wrote:It happened once that an opponent (Roman Usmanoff, you can look at that game if you want) waited until he had 1 day, then he moved. He played the whole game in zeitnot and when his position got hopeless he lost on time. :lol:
Haha! I actually lost 15 days in 4 of my games. What happened is that I had other games with less that 15 days on the clock, and attended them first, and didn't make a move at all on those 4 until they were games with the lowest time on the clock... turned out to be a terrible idea!

But I wonder if Usmanoff did the same, having lots of games with 1 day left on the clock and letting it run until it was the one to attend, with bad consequences! :)
Your beliefs create your reality, so be careful what you wish for.