Designing an analysis friendly Stockfish?

Code, algorithms, languages, construction...
Post Reply
Jeremy Bernstein
Site Admin
Posts: 1226
Joined: Wed Jun 09, 2010 7:49 am
Real Name: Jeremy Bernstein
Location: Berlin, Germany
Contact:

Re: Designing an analysis friendly Stockfish?

Post by Jeremy Bernstein » Thu Feb 03, 2011 7:16 am

Prima wrote:Jeremey thanks for your time and assistance. Unfortunatle, it still did not compile here in VS2010 GUI. I still got the 'Output' message though. Heres' the error message:

Which leads me to another thing I've been curious about; (1) as you've seen, the stockfish 2.01pa-gtb's source has it's own source files in it. (2)Within this src folder, there's the 'egtb' folder which has gtb-related files, the progname.h, tbprobe.c, and version.h files in it. (3) Within this egtb folder, there are sysport folder, gtb folder, and compression folder.
(4) Within the compression folder, there is the "wrap.c/wrap.h source files + huffman folder with its own hzip.c/h; the liblzf folder with its izf.h, c.c, d.c, h source files; the lzma folder with its source files, and the zlib folder with its own source.

With all these sub folders within the stockfish source, would it be better if I moved all the sources from the sub folders to the main stockfish source folder and compile, OR, do I have to keep using the "Add items" function from the VS Compile GUI till everything is added and then move to "Build" it?

Kingliveson had suggested (or at least inferred) that in Windows OS, he would move all source related files from sub folders to the main one or have everything in one place as Windows likes it this way. I tried this with Stockfish-gtb but still got errors. Attempting to compile via Command prompt (as thought by gaard), I still get this errors and never successful in compiling.

If I just "Add items" exclusively from its main source folder, it still won't compile. Which is the better solution here? Thanks in advance.
If you imported my project, the egtb files would have been compiled, too -- what changed? Look at the readme which comes with the Gaviota probing software: you have to a) compile those .c files (a list is given, but it's the ones there, with the exception of tprobe.c), b) add the .h files' paths to the search path (adding the enclosing folders to the list of additional #includes) and c) add a couple of items to the preprocessor defines list.

jb

fruity
Posts: 29
Joined: Wed Feb 02, 2011 12:52 am

Re: Designing an analysis friendly Stockfish?

Post by fruity » Thu Feb 03, 2011 8:47 am

Uly wrote:Thanks fruity and gaard, here's a quick comparison of Stockfish PA_G and PA_H at 1CPU in the opening position. It seemed mostly luck, but PA_H found 1...e6 much earlier and reached depth 24 much faster, PA_G caught up at depth 25 and finished one minute faster in the end, though.
Engine: Stockfish 2.0.1 PA_G (128 MB)
by Tord Romstad, Marco Costalba, Joona Kii
 15/14	 0:00 	+0.16--	1.Nf3 Nf6 2.e3 d5 3.d4 e6 4.Bd3 c5 5.O-O c4 6.Be2 Nc6 7.Nc3 Bd6 (509.807) 679
 15/09	 0:01 	+0.32++	1.e4 Nf6 2.e5 Nd5 3.Nf3 Nc6 4.d4 e6 5.Bd3 (928.123) 715
 15/09	 0:01 	+0.40++	1.e4 Nf6 2.e5 Nd5 3.Nf3 Nc6 4.d4 e6 5.Bd3 (1.152.385) 730
 15/09	 0:01 	+0.56++	1.e4 Nf6 2.e5 Nd5 3.Nf3 Nc6 4.d4 e6 5.Bd3 (1.424.940) 741
 15/16	 0:03 	+0.44 	1.e4 e5 2.Nf3 Bd6 3.Nc3 Nf6 4.Be2 Nc6 5.O-O O-O 6.d3 b6 7.d4 exd4 8.Nxd4 Bb7 (2.247.548) 749
 16/18	 0:04 	+0.24--	1.e4 e5 2.Nf3 Nf6 3.Nxe5 d6 4.Nf3 Nxe4 5.Bd3 Nf6 6.O-O Be7 7.Nc3 O-O 8.Re1 Nc6 9.Ng5 d5 (3.151.485) 746
 16/26	 0:05 	+0.32 	1.e4 e5 2.Nf3 Nf6 3.Nxe5 d6 4.Nf3 Nxe4 5.Qe2 Qe7 6.Nc3 Nxc3 7.dxc3 Qxe2+ 8.Bxe2 Nc6 9.Be3 Be7 10.O-O-O O-O 11.Kb1 Be6 12.Ng5 a6 13.Nxe6 fxe6 (4.052.349) 747
 17/26	 0:05 	+0.32 	1.e4 e5 2.Nf3 Nf6 3.Nxe5 d6 4.Nf3 Nxe4 5.Qe2 Qe7 6.Nc3 Nxc3 7.dxc3 Qxe2+ 8.Bxe2 Nc6 9.Be3 Be7 10.O-O-O O-O 11.Kb1 Be6 12.Ng5 a6 13.Nxe6 fxe6 (4.252.062) 745
 18/26	 0:06 	+0.32 	1.e4 e5 2.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xd6 10.Nbd2 Re8 11.Qc2 Qf4 12.Rfe1 Bg4 13.Qb3 (57.654.660) 741
 23/22	 1:28 	+0.20 	1.e4 e6 2.Nf3 d5 3.exd5 exd5 4.d4 Nf6 5.Bd3 Bd6 6.Nc3 Nc6 7.O-O O-O 8.Bg5 Nb4 9.Nb5 Bg4 10.Re1 h6 11.Nxd6 Qxd6 (65.272.603) 739
 24/10	 1:45 	+0.28++	1.e4 e6 2.Nf3 d5 3.exd5 exd5 4.d4 Nf6 5.Bd3 Bd6 (77.754.590) 736
 24/26	 1:57 	+0.28 	1.e4 e6 2.Nf3 d5 3.exd5 exd5 4.d4 Nf6 5.Bd3 Nc6 6.O-O Be7 7.Bf4 Bg4 8.c3 O-O 9.Nbd2 Bd6 10.Bxd6 Qxd6 11.Qb3 b6 12.Rae1 Rae8 13.h3 Bh5 (86.755.475) 735
 25/20	 2:44 	+0.20--	1.e4 e6 2.Nf3 d5 3.exd5 exd5 4.d4 Nf6 5.Bd3 Nc6 6.O-O Be7 7.Bf4 O-O 8.Nc3 Bg4 9.Nb5 a6 10.Nxc7 Rc8 (120.464.810) 733
 25/18	 3:49 	+0.12--	1.e4 e6 2.Nf3 d5 3.exd5 exd5 4.Be2 Nf6 5.O-O Bd6 6.d4 O-O 7.Nc3 Re8 8.Bg5 c6 9.Be3 Qe7 (168.546.917) 733
 25/24	 6:10 	+0.20 	1.e4 e6 2.Nf3 d5 3.exd5 exd5 4.Nc3 Nf6 5.d4 Bb4 6.Bd3 Qe7+ 7.Be3 Ng4 8.Qe2 Nxe3 9.Qxe3 Nc6 10.O-O Bxc3 11.bxc3 Qxe3 12.fxe3 O-O (272.208.066) 734
best move: e2-e4 time: 6:12.578 min
The change regarding history and killer moves seems to work well only at lower depths. I'm actually running a 1000 games 20 sec. match, 6 Threads. SF default is clearly in front after 800 games. I'll test SF PA_G against SF default at longer tc tonight.

User avatar
Uly
Posts: 838
Joined: Thu Jun 10, 2010 5:33 am

Re: Designing an analysis friendly Stockfish?

Post by Uly » Thu Feb 03, 2011 8:56 am

Thanks fruity, would it be possible to make the new code conditional, so that it's only used at low depth but the original behavior is used at higher depth?

Jeremy Bernstein
Site Admin
Posts: 1226
Joined: Wed Jun 09, 2010 7:49 am
Real Name: Jeremy Bernstein
Location: Berlin, Germany
Contact:

Re: Designing an analysis friendly Stockfish?

Post by Jeremy Bernstein » Thu Feb 03, 2011 1:40 pm

Jeremy Bernstein wrote:If you imported my project, the egtb files would have been compiled, too -- what changed? Look at the readme which comes with the Gaviota probing software: you have to a) compile those .c files (a list is given, but it's the ones there, with the exception of tprobe.c), b) add the .h files' paths to the search path (adding the enclosing folders to the list of additional #includes) and c) add a couple of items to the preprocessor defines list.

jb
Here's a VS 2010 project with all of the targets. You may just want to adjust the optimization settings. I have it set to use OLD_LOCKS, so that it runs under XP. Since my OS is 32-bit, I couldn't PGO the 64-bit version. I leave that as an exercise to the reader. 32-bit PGO version in Release/Win32/

http://www.expr-i0.net/stock_pa_gtb_2010.7z

fruity
Posts: 29
Joined: Wed Feb 02, 2011 12:52 am

Re: Designing an analysis friendly Stockfish?

Post by fruity » Thu Feb 03, 2011 3:45 pm

Uly wrote:Thanks fruity, would it be possible to make the new code conditional, so that it's only used at low depth but the original behavior is used at higher depth?
Might be possible, but let's first wait and see how SF PA_G compares to SF default with 1000 20 sec games and 6 threads for each side.
SF PA_H was 10 Elo below SF default under those conditions. Exact numbers will follow.

Jeremy Bernstein
Site Admin
Posts: 1226
Joined: Wed Jun 09, 2010 7:49 am
Real Name: Jeremy Bernstein
Location: Berlin, Germany
Contact:

Re: Designing an analysis friendly Stockfish?

Post by Jeremy Bernstein » Thu Feb 03, 2011 4:11 pm

Here's another 32-bit PGO build which won't require a runtime library install. It appears to be competitive with the JA compile in speed.

http://www.expr-i0.net/Stockfish_201_PA_GTB_Win32.zip

Jeremy Bernstein
Site Admin
Posts: 1226
Joined: Wed Jun 09, 2010 7:49 am
Real Name: Jeremy Bernstein
Location: Berlin, Germany
Contact:

Re: Designing an analysis friendly Stockfish?

Post by Jeremy Bernstein » Thu Feb 03, 2011 4:32 pm

When I have the gtbs installed, I get tbhits of 171800086257 all the time. Looks like the member variable is simply uninitialized. Can I simply set tbhits = 0 in Position::Position? Looks like it. It would be good to add some bench positions which exercise the tbs for profiling purposes, as well...

UPDATE: the 32-bit version linked above has been replaced with a version which a) properly initialized the tbhits count and b) does some amount profiling in tb code.

Peter C
Posts: 154
Joined: Thu Jun 10, 2010 3:12 am
Real Name: Peter C

Re: Designing an analysis friendly Stockfish?

Post by Peter C » Thu Feb 03, 2011 4:47 pm

Jeremy Bernstein wrote:I needed to change a couple of lines in egtb.cpp: you were initializing the Chess960 variable before the Options map was ready, causing an annoying crash on my system.
Oops. Must have forgot to change that and just blindly copied it from my 1.9 port... (UCI options were retrieved differently on 1.9). Thanks for pointing this out.
Jeremy Bernstein wrote:When I have the gtbs installed, I get tbhits of 171800086257 all the time. Looks like the member variable is simply uninitialized. Can I simply set tbhits = 0 in Position::Position? Looks like it. It would be good to add some bench positions which exercise the tbs for profiling purposes, as well...
Weird. It always works for me. Sure, simply set tbhits = 0 to fix it, it shouldn't mess anything up, and it's something I should have done anyway... ;)

Peter

Jeremy Bernstein
Site Admin
Posts: 1226
Joined: Wed Jun 09, 2010 7:49 am
Real Name: Jeremy Bernstein
Location: Berlin, Germany
Contact:

Re: Designing an analysis friendly Stockfish?

Post by Jeremy Bernstein » Thu Feb 03, 2011 4:50 pm

It might be worthwhile to put this code up on github, so that we don't have to keep passing archives around. Any objections?

UPDATE: new version at link above. Seems to be the fastest so far, with some additional profiling. I added a new parameter to the "bench" mode to set the number of pvs. So "stockfish bench 128 4 10 default depth 2" will use a 128MB transposition table, 4 threads, search to depth 10, using the default FENs, and 2 pvs.

Peter C
Posts: 154
Joined: Thu Jun 10, 2010 3:12 am
Real Name: Peter C

Re: Designing an analysis friendly Stockfish?

Post by Peter C » Thu Feb 03, 2011 9:06 pm

My only objection is that UEStudio doesn't have built-in Git support, but feel free to do it anyway. Probably a good idea.

Peter

Post Reply