max amount of moves from a position?

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

Dann Corbit
Posts: 12538
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: max amount of moves from a position?

Post by Dann Corbit »

JVMerlino wrote:
jwes wrote:
Dann Corbit wrote:Sure, but I think it would be difficult to generate a lot more promotion choices than that setup.
You can certainly add a few.
[D]rnbqqbnr/PPPPPPPP/8/3ppp2/3pkp2/3N1N2/4K3/8 w - - 0 1
If the goal is to test your move generator, then no problem. If the goal is to try to blow up your search, change the two white Knights to Rooks, as the current position is Mate in 1 (Nf2).

[D]rnbqqbnr/PPPPPPPP/8/3ppp2/3pkp2/3R1R2/4K3/8 w - - 0 1

I let Stockfish think for three minutes (on a very slow machine, relatively) and it still couldn't find mate, although the score is +51.75.

jm
It is a mate in 8 according to Chest:
rnbqqbnr/PPPPPPPP/8/3ppp2/3pkp2/3R1R2/4K3/8 w - - acn 48259749; acs 81; bm fxe8=Q; ce 32752; dm 8; pv fxe8=Q Rxh7 Rxf4+ Kxf4 Rxd4+ e4 cxb8=Q+ Rxb8 axb8=Q+ Qc7 Qxc7+ Kg4 Qg6+ Kh4 Qh2#;

Your version of the position was also much prettier than mine.
mcostalba
Posts: 2684
Joined: Sat Jun 14, 2008 9:17 pm

Re: max amount of moves from a position?

Post by mcostalba »

JVMerlino wrote: [D]rnbqqbnr/PPPPPPPP/8/3ppp2/3pkp2/3R1R2/4K3/8 w - - 0 1

I let Stockfish think for three minutes (on a very slow machine, relatively) and it still couldn't find mate, although the score is +51.75.

jm
Current development version seems to find the mate quickly enough on my slow notebook (see nps).

Code: Select all

Searching: rnbqqbnr/PPPPPPPP/8/3ppp2/3pkp2/3R1R2/4K3/8/ w - -
infinite: 0 ponder: 0 time: 0 increment: 0 moves to go: 0
 1   +3.43   00:00     543  fxe8=Q 
 2  +12.32   00:00     837  fxe8=Q Qxe8 dxe8=Q 
 3  +19.39   00:00    5794  fxe8=Q Qxd7 gxh8=Q Qxe8 exf8=Q 
 4  +19.39   00:00    6602  fxe8=Q Qxd7 gxh8=Q Qxe8 exf8=Q 
 5  +24.48   00:00   12292  fxe8=Q Qxe8 dxe8=Q Rxh7 exf8=Q Rh2+ Kf1 
 6  +24.20   00:00   27523  fxe8=Q Rxa7 exd8=Q Ra2+ Kf1 Ra1+ Kg2 Ra2+ Kg1 Ra1+ 
                            Kg2 
 7  +26.10   00:00   78394  fxe8=Q Qxe8 dxe8=Q Rxa7 gxh8=Q Ra2+ Kf1 Ra1+ Kg2 
                            Ra2+ Kh3 
 8  +31.92   00:00  298120  fxe8=Q Qxd7 exf8=Q Nc6 gxh8=Q Qxe8 bxa8=Q Qxf8 
                            hxg8=Q Qxg8 Qxg8 
 9  +35.52   00:01  493832  fxe8=Q Qxe7 gxh8=Q Rxa7 hxg8=Q Ra2+ Kf1 Ra1+ Kg2 
                            Ra2+ Kh3 Rh2+ Kxh2 Bxd7 Qxe7 
10  +38.18   00:02   1022K  fxe8=Q Rxh7 exd8=Q Rh2+ Kf1 Bxb7 gxf8=Q Nc6 Qxa8 
                            Bxa8 d8=Q Nxd8 cxd8=Q 
11  +41.13   00:06   2438K  fxe8=Q Rxa7 exd8=Q Ra2+ Kd1 Bxg7 dxc8=Q Ne7 cxb8=Q 
                            Nxc8 bxc8=Q Rxe8 Qxe8 Ra1+ Kc2 Ra2+ Kb3 
12  +44.57   00:12   5080K  fxe8=Q Rxh7 exd8=Q Nxd7 bxa8=Q Rh2+ Kf1 Ne7 gxf8=Q 
                            Nxf8 Qdxe7 Rh1+ Kg2 
13  +96.20   00:32  13995K  fxe8=Q Rxh7 Rxf4+ Kxf4 Rxd4+ Kg3 Qg6+ Kh2 Qxh7+ Kg2 
                            Qg6+ Kh3 Qxf5+ Kg3 Qf3+ Kh2 Rh4+ 
14     #13   00:32  13996K  fxe8=Q Rxh7 Rxf4+ Kxf4 Rxd4+ Kg3 Qg6+ Kh2 Qxh7+ Kg2 
                            Qg6+ Kh3 Qxf5+ Kg3 Qf3+ Kh2 Rh4+ 
15     #13   00:32  13996K  fxe8=Q Rxh7 Rxf4+ Kxf4 Rxd4+ Kg3 Qg6+ Kh2 Qxh7+ Kg2 
                            Qg6+ Kh3 Qxf5+ Kg3 Qf3+ Kh2 Rh4+ 
Nodes: 13996377
Nodes/second: 434467
Best move: fxe8=Q
Ponder move: Rxh7
JVMerlino
Posts: 1357
Joined: Wed Mar 08, 2006 10:15 pm
Location: San Francisco, California

Re: max amount of moves from a position?

Post by JVMerlino »

mcostalba wrote:
JVMerlino wrote: [D]rnbqqbnr/PPPPPPPP/8/3ppp2/3pkp2/3R1R2/4K3/8 w - - 0 1

I let Stockfish think for three minutes (on a very slow machine, relatively) and it still couldn't find mate, although the score is +51.75.

jm
Current development version seems to find the mate quickly enough on my slow notebook (see nps).

Code: Select all

Searching: rnbqqbnr/PPPPPPPP/8/3ppp2/3pkp2/3R1R2/4K3/8/ w - -
infinite: 0 ponder: 0 time: 0 increment: 0 moves to go: 0
 1   +3.43   00:00     543  fxe8=Q 
 2  +12.32   00:00     837  fxe8=Q Qxe8 dxe8=Q 
 3  +19.39   00:00    5794  fxe8=Q Qxd7 gxh8=Q Qxe8 exf8=Q 
 4  +19.39   00:00    6602  fxe8=Q Qxd7 gxh8=Q Qxe8 exf8=Q 
 5  +24.48   00:00   12292  fxe8=Q Qxe8 dxe8=Q Rxh7 exf8=Q Rh2+ Kf1 
 6  +24.20   00:00   27523  fxe8=Q Rxa7 exd8=Q Ra2+ Kf1 Ra1+ Kg2 Ra2+ Kg1 Ra1+ 
                            Kg2 
 7  +26.10   00:00   78394  fxe8=Q Qxe8 dxe8=Q Rxa7 gxh8=Q Ra2+ Kf1 Ra1+ Kg2 
                            Ra2+ Kh3 
 8  +31.92   00:00  298120  fxe8=Q Qxd7 exf8=Q Nc6 gxh8=Q Qxe8 bxa8=Q Qxf8 
                            hxg8=Q Qxg8 Qxg8 
 9  +35.52   00:01  493832  fxe8=Q Qxe7 gxh8=Q Rxa7 hxg8=Q Ra2+ Kf1 Ra1+ Kg2 
                            Ra2+ Kh3 Rh2+ Kxh2 Bxd7 Qxe7 
10  +38.18   00:02   1022K  fxe8=Q Rxh7 exd8=Q Rh2+ Kf1 Bxb7 gxf8=Q Nc6 Qxa8 
                            Bxa8 d8=Q Nxd8 cxd8=Q 
11  +41.13   00:06   2438K  fxe8=Q Rxa7 exd8=Q Ra2+ Kd1 Bxg7 dxc8=Q Ne7 cxb8=Q 
                            Nxc8 bxc8=Q Rxe8 Qxe8 Ra1+ Kc2 Ra2+ Kb3 
12  +44.57   00:12   5080K  fxe8=Q Rxh7 exd8=Q Nxd7 bxa8=Q Rh2+ Kf1 Ne7 gxf8=Q 
                            Nxf8 Qdxe7 Rh1+ Kg2 
13  +96.20   00:32  13995K  fxe8=Q Rxh7 Rxf4+ Kxf4 Rxd4+ Kg3 Qg6+ Kh2 Qxh7+ Kg2 
                            Qg6+ Kh3 Qxf5+ Kg3 Qf3+ Kh2 Rh4+ 
14     #13   00:32  13996K  fxe8=Q Rxh7 Rxf4+ Kxf4 Rxd4+ Kg3 Qg6+ Kh2 Qxh7+ Kg2 
                            Qg6+ Kh3 Qxf5+ Kg3 Qf3+ Kh2 Rh4+ 
15     #13   00:32  13996K  fxe8=Q Rxh7 Rxf4+ Kxf4 Rxd4+ Kg3 Qg6+ Kh2 Qxh7+ Kg2 
                            Qg6+ Kh3 Qxf5+ Kg3 Qf3+ Kh2 Rh4+ 
Nodes: 13996377
Nodes/second: 434467
Best move: fxe8=Q
Ponder move: Rxh7
Interesting. Well, using 2.1.1 on a 32-bit machine, I was getting about 365Kns and no mate was announced as of depth 15. And even though I waited for several more minutes, this was the last output I got:

Code: Select all

info depth 15
info currmove f7e8q currmovenumber 1
info depth 15 seldepth 28 multipv 1 score cp 11996 nodes 33865639 nps 365490 time 92658 pv f7e8q h8h7 f3f4 e4f4 d3d4 f4g3 e8g6 g3h2 g6h7 h2g3 h7h4 g3g2 h4g5 g2h2 d4h4
info depth 16
info nodes 33865639 nps 365368 time 92689
info currmove f7e8q currmovenumber 1
jm
User avatar
Don
Posts: 5106
Joined: Tue Apr 29, 2008 4:27 pm

Re: max amount of moves from a position?

Post by Don »

perft could be rigged to track the maximum number of moves from a position in a way that has some practical meaning. Of course it can only cover a tiny subset of the search space, but it would be interesting to know from the perft(13) test what the maximum number of moves seen going out to depth 13 from the opening position. It would probably be either reassuring or alarming from the point of view of programs which have fixed size move lists.

You are not likely to get positions with 80, 90, 100+ legal moves (in a standard chess program) unless you specifically set it up. To have a wide open position and MAINTAIN it without captures is very unlikely in a modern chess program which tries very hard not to spend much time on unlikely positions. So as soon as the position gets open the capture tree tends to be explored first and this keeps things sane.

I set Komodo up to notice the most move rich position and it had a difficult time finding positions in it's normal search that exceeded 60 moves. It had to do an 18 ply search to find the first position with over 60 moves for one side. It did not try to count moves in positions where there was a cutoff as most of those don't get generated anyway. Also, most under-promotions do not get counted.

Here is a position found during a 23 ply search with 65 moves possible for white:

[d]r1bq1rk1/pp2bppp/2n1pn2/7Q/3N4/2NBP3/PP1B1PPP/R3K2R w - - 0 1[/d]

A couple of things I noticed is that first of all the position does not look that complicated and I was surprised to see a bishop that was not very mobile. But the knights were highly mobile and together have a non-trivial number of legal moves.