Shogi Perft numbers

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

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

Re: Shogi Perft numbers

Post by hgm »

Patrice Duhamel wrote: Sat Aug 24, 2019 11:23 am What GUI are using USI protocol ?
Shogidogoro, BCM Games and gShogi. And perhaps Tagua.
Ferdy
Posts: 4833
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: Shogi Perft numbers

Post by Ferdy »

Patrice Duhamel wrote: Sat Aug 24, 2019 11:23 am What GUI are using USI protocol ?
There is also ShogiGui, and of course Winboard.
IanO
Posts: 496
Joined: Wed Mar 08, 2006 9:45 pm
Location: Portland, OR

Re: Shogi Perft numbers

Post by IanO »

I've never concerned myself with perft in my game programs before, but is it supposed to detect checkmates in order to avoid playing past fools mates? I was wondering if

Code: Select all

perft 7
could be used to enumerate all the shortest mates in shogi.
User avatar
hgm
Posts: 27789
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Shogi Perft numbers

Post by hgm »

Sure. Perft only considers legal moves, so it cannot calculate past stalemate or checkmate. It does calculate past 3-fold reps, though.
Patrice Duhamel
Posts: 193
Joined: Sat May 25, 2013 11:17 am
Location: France
Full name: Patrice Duhamel

Re: Shogi Perft numbers

Post by Patrice Duhamel »

IanO wrote: Wed Sep 04, 2019 1:08 am I've never concerned myself with perft in my game programs before, but is it supposed to detect checkmates in order to avoid playing past fools mates? I was wondering if

Code: Select all

perft 7
could be used to enumerate all the shortest mates in shogi.
There are 29 mate positions at depth 7 :

Code: Select all

nodes = 15 086 269 607 
Captures = 156 289 904 
Promotions = 78 496 954 
Drops = 22 189 844 
Checks = 79 636 812 
Mates = 29
Anything that can go wrong will go wrong.
IanO
Posts: 496
Joined: Wed Mar 08, 2006 9:45 pm
Location: Portland, OR

Re: Shogi Perft numbers

Post by IanO »

Patrice Duhamel wrote: Wed Sep 04, 2019 6:34 pm
IanO wrote: Wed Sep 04, 2019 1:08 am I've never concerned myself with perft in my game programs before, but is it supposed to detect checkmates in order to avoid playing past fools mates? I was wondering if

Code: Select all

perft 7
could be used to enumerate all the shortest mates in shogi.
There are 29 mate positions at depth 7 :

Code: Select all

nodes = 15 086 269 607 
Captures = 156 289 904 
Promotions = 78 496 954 
Drops = 22 189 844 
Checks = 79 636 812 
Mates = 29
Thanks! Those stats were perfect for verifying the shogi perft I wrote this weekend. Turns out there are 11 unique 7-move mate positions in shogi, expressing 6 themes:

[d]lnfw1wfnl/5rkb1/pppppppWp/9/9/9/PPPPPPP1P/1B5R1/LNFWKWFNL b

[d]lnfw1kQnl/1r2wB3/pppppp1pp/6p2/9/2P6/PP1PPPPPP/7R1/LNFWKWFNL b

[d]lnfw1w1nl/1r2kB1b1/ppppFp1pp/4p4/9/2P6/PP1PPPPPP/7R1/LNFWKWFNL b

[d]lnfww1Qnl/1r2k2b1/ppppFpppp/4p4/9/P8/1PPPPPPPP/7R1/LNFWKWFNL b

[d]lnfwB2nl/1r2kWfb1/pppppp1pp/9/9/2P6/PP1PPPPPP/7R1/LNFWKWFNL b

[d]lnf3fnl/1rwkWQ1b1/pppppp1pp/9/9/2P6/PP1PPPPPP/7R1/LNFWKWFNL b

The 29 transpositions and 5 other mate positions are left as an exercise for the reader. :)

(The fairy FEN support here doesn't support the "+P" style of indicating promoted pieces as in SFEN. I've used 'W' for promoted pawn (same as for gold general) and 'Q' for promoted bishop.)
User avatar
hgm
Posts: 27789
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Shogi Perft numbers

Post by hgm »

[d]lnf3fnl/1rwkWI1b1/pppppp1pp/9/9/2P6/PP1PPPPPP/7R1/LNFWKWFNL b
Yeah, sorry about that. The diagram script still needs some work for the support of fairy pieces, which I so far postponed. For one, I would like to support all XBoard pieces, of which there are now 66, and obvioulsy 1-letter encoding will fail. The symbols XBoard's default theme uses for Shogi Horse and Dragon are currently available as I and J, but I don't think the Gold-like symbols for promoted P, N, L, S can currently be selected.

Of course +P, +N, +L and +S would be obvious choices for their two-character IDs, and +B, +R would be preferable over I, J. To further expand the set I was thinking of punctuation suffixes on the letters, like L', L`, L" or L!
Patrice Duhamel
Posts: 193
Joined: Sat May 25, 2013 11:17 am
Location: France
Full name: Patrice Duhamel

Re: Shogi Perft numbers

Post by Patrice Duhamel »

hgm wrote: Tue Sep 10, 2019 12:57 pm [d]lnf3fnl/1rwkWI1b1/pppppp1pp/9/9/2P6/PP1PPPPPP/7R1/LNFWKWFNL b
Why "Black" and "White" are inverted in Winboard ?
In others GUI Black is the first player.

Code: Select all

Winboard :
lns3snl/1rgkG+B1b1/pppppp1pp/9/9/2P6/PP1PPPPPP/7R1/LNSGKGSNL[P] b 0 4

ShogiGUI or BCMGames :
lns3snl/1rgkG+B1b1/pppppp1pp/9/9/2P6/PP1PPPPPP/7R1/LNSGKGSNL w P 8
Anything that can go wrong will go wrong.
User avatar
hgm
Posts: 27789
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Shogi Perft numbers

Post by hgm »

In other Chess variants white is first player.

WinBoard uses ordinary FEN as part of CECP. ShogiGUI and BCMgames uses the incompatible SFEN as part of USI.