Shogi

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Shogi

Post by Evert »

Evert wrote:
Evert wrote:
I guess one could keep a sort of drop-history table, and sort by that.
Oops. :oops:
I actually have one of those, but it ends up never being used for sorting moves in the end…

Guess I'll have to fix that next.
This actually looks like a very nice improvement so-far: scoring 55% at the moment.
Crept up to 58% overnight, seeing if I can squeeze some more juice out of it. The main savings seem to come from reducing poor drops more than before (because they end up having a lower score and are further down in the move list).
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Shogi

Post by Evert »

I'm currently trying the following:

If the search of a move comes back with a normal score, but the null-move score indicates a mate-threat against us, and if the move is a checking move and the evasion is a capture, then extend the search by one extra ply and search the move again.

This seems to get triggered rarely, once or twice in 10-20% of games, and it's not obvious from looking at where it triggered if it would actually help. Test is running, currently at 51% but well within the uncertainty. It may get triggered more often at longer time controls though, so I guess I'd need to run it for that too.
Ferdy
Posts: 4833
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: Shogi

Post by Ferdy »

Evert wrote:Is there a consensus on the ordering of drop moves?

I don't mean where they should be in the move list, though that is an interesting debate as well (I order them as late as possible, and keep a separate history table for them as well). What I mean is: should a pawn drop be searched before a rook drop, or not? I originally had it so more valuable piece drops were tried first, but I wonder if it wouldn't be better to keep powerful pieces in reserve. The test is currently running and so far it looks like my initial ordering is best, but I'd be curious to hear about other ideas.

I'm also considering if it's worthwhile to extend if it turns out that the best move is a check-drop, which gets countered by an immediate capture, while the null-move search returned a mate score. This suggests that we're just trying to push a mate score over the horizon. Any thoughts on this?
So far I generate drop moves late, except in check evasion where in mini shogi you have to drop a piece to parry opponents threat, it is not good to move a piece as a cover since it is more likely that the squares it attacks before will now become weak and also the square that it vacates will become a target of opponent's drop moves. I also ordered drop moves depending on the drop squares, undefended empty square near my king will get more ordering points, also points are added for those empty squares that has protection from my pieces say infront of gold, silver, pawn or at side of gold or at diagonal of silver.
I tried safe (by SEE) drop check in qsearch at depth 0 when alpha is not improved by capture moves, and it won some points. I don't do drop moves in qsearch only capture moves. But If in check at depth >= -1, I don't use the standpat score to decide to exit or not but instead I generate evasion to resolve checks on this depth and it also won some points on self-tests.
I have not tried the drop history stuff yet. But from initial test results, my history for non-capture, and non-promote moves are not effective so far. It seems to me that ordering this ordinary moves by occupying the central squares are enough, as this game is dominated by captures, and drops. I always extend when in check, safe or unsafe checks in main search.
Ferdy
Posts: 4833
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: Shogi

Post by Ferdy »

Evert wrote:I'm currently trying the following:

If the search of a move comes back with a normal score, but the null-move score indicates a mate-threat against us, and if the move is a checking move and the evasion is a capture, then extend the search by one extra ply and search the move again.

This seems to get triggered rarely, once or twice in 10-20% of games, and it's not obvious from looking at where it triggered if it would actually help. Test is running, currently at 51% but well within the uncertainty. It may get triggered more often at longer time controls though, so I guess I'd need to run it for that too.
If the search of a move comes back with a normal score,
What do you mean by normal score here? How this score compares with alpha?
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Shogi

Post by Evert »

Ferdy wrote: So far I generate drop moves late, except in check evasion where in mini shogi you have to drop a piece to parry opponents threat, it is not good to move a piece as a cover since it is more likely that the squares it attacks before will now become weak and also the square that it vacates will become a target of opponent's drop moves. I also ordered drop moves depending on the drop squares, undefended empty square near my king will get more ordering points, also points are added for those empty squares that has protection from my pieces say infront of gold, silver, pawn or at side of gold or at diagonal of silver.
Sounds sensible. It may be a bit specific, but I could certainly try preferring drop moves during evasion generation.
I tried safe (by SEE) drop check in qsearch at depth 0 when alpha is not improved by capture moves, and it won some points.
I tried something like this, but unfortunately it didn't work for me. It may be that the issue is in "something like this" rather than "exactly like this"...
I don't do drop moves in qsearch only capture moves. But If in check at depth >= -1, I don't use the standpat score to decide to exit or not but instead I generate evasion to resolve checks on this depth and it also won some points on self-tests.
Yes, I do all of those too.
I have not tried the drop history stuff yet. But from initial test results, my history for non-capture, and non-promote moves are not effective so far.
I haven't tested the effectiveness of the general history stuff very thoroughly, but part of the reason I separated drop moves from it is that I suspect they will simply pollute the history table.
By the way, there is still some additional static ordering on top of the history stuff: I give a bonus to drops around the (enemy) king and a penalty to drops that are far away from the king or the enemy side of the board. I always factor in SEE as well.
It seems to me that ordering this ordinary moves by occupying the central squares are enough, as this game is dominated by captures, and drops. I always extend when in check, safe or unsafe checks in main search.
This may be true for mini-shogi, where the board is so small. However, Sjaak's search and evaluation are generic, and then it depends on whether something works across variants or not.
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Shogi

Post by Evert »

Ferdy wrote: What do you mean by normal score here? How this score compares with alpha?
No, just that it is a non-mate score. Placing extra restrictions didn't seem to improve the idea though. In fact, the thing ended up testing as equal within the error bars (few Elo), so it seems the idea is flawed...
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Shogi

Post by Evert »

What is quite funny, but a little worrying, is that in many games Sjaak and GNUShogi show similar evals, but with the opposite sign. GNUShogi builds up a castle around its king, which Sjaak neglects to do, but since there is no pressure against the king it isn't penalised for this. GNUShogi then sits around waiting while Sjaak starts gobbling up pieces one by one, until GNUShogi is in zugzwang and has to dismantle its castle.

I should probably penalise Sjaak for not building a castle before there is pressure against the king, because it may be too late otherwise.
Ferdy
Posts: 4833
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: Shogi

Post by Ferdy »

Evert wrote:
Ferdy wrote:I have not tried the drop history stuff yet. But from initial test results, my history for non-capture, and non-promote moves are not effective so far.
I haven't tested the effectiveness of the general history stuff very thoroughly, but part of the reason I separated drop moves from it is that I suspect they will simply pollute the history table.
By the way, there is still some additional static ordering on top of the history stuff: I give a bonus to drops around the (enemy) king and a penalty to drops that are far away from the king or the enemy side of the board. I always factor in SEE as well.
Result of test between the one using the history for non-drop, non-capture and non-promote moves (or ordinary moves) vs. the one without using history, the one using the history won.

Then I make a new version to use history for drop moves and it won vs the one without using the drop history. Both of these version are using history for ordinary moves. Perhaps the use of history complements to the use of LMR. Note that the version that uses drop history does not use my old trick of giving bonus for drops that are protected by on-board pieces.
I have not tried yet using SEE on drop moves, except those selected safe drop check moves in qsearch().

Not really a serious test, but just to see which methods has potential.
v1-38 is based on v1-35, but has drop history.
v1-37 is based on v1-35, but has no ordinary move history, but uses pst.
Shokidoki Yokohama T04 is using time odds of 4.

From bayeselo.
Mini shogi games based on TC 3min + 1sec/move inc.

Code: Select all

   1 Lima v1-38 x64 popcnt    103.1     116 (   69.0 :    47.0)  59.5%  
                                        116 (   69.0 :    47.0)  59.5%  Lima v1-35 x64 popcnt     36.8

   2 Lima v1-35 x64 popcnt     36.8     692 (  356.0 :   336.0)  51.4%  
                                        116 (   47.0 :    69.0)  40.5%  Lima v1-38 x64 popcnt    103.1
                                        181 (   91.0 :    90.0)  50.3%  Lima v1-36 x64 popcnt     34.7
                                         42 (   21.0 :    21.0)  50.0%  Shokidoki Yokohama T04    32.9
                                        170 (   89.0 :    81.0)  52.4%  Lima v1-34a x64 popcnt    20.4
                                         98 (   57.0 :    41.0)  58.2%  Lima v1-37 x64 popcnt    -19.9
                                         42 (   22.0 :    20.0)  52.4%  TJshogi5x5 0.19          -32.3
                                         43 (   29.0 :    14.0)  67.4%  NebiyuAlien_1.46         -32.9
User avatar
hgm
Posts: 27790
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Shogi

Post by hgm »

Evert wrote:What is quite funny, but a little worrying, is that in many games Sjaak and GNUShogi show similar evals, but with the opposite sign. GNUShogi builds up a castle around its king, which Sjaak neglects to do, but since there is no pressure against the king it isn't penalised for this. GNUShogi then sits around waiting while Sjaak starts gobbling up pieces one by one, until GNUShogi is in zugzwang and has to dismantle its castle.
Indeed, the worst of GNU Shogi is its completely passive attitude. (Although that it sometimes fails to see it is mated in one or two of course also doesn't help.) I once tried handicap games between GNU and Shokidoki, where the latter had to pley without R and B. GNU then just tugs away the extra R and B in a safe place, and gets eaten on the rest of the board anyway...

It is hard to make an eval that spontaneously builds a decent castle. Against other engines it is also not very helpful, as the strong ones are based on tons of knowledge. So if you build a proper castle, they will know very well how to dismantle it. If it looks more like a pile of rubble, however, they don't know what to make of it either. They evaluate your position as very bad, but cannot really exploit that.

Shokidoki scores some 20-25% against SPEAR in regular Shogi, and in all games SPEAR's score quickly rises to +8, just because of the difference in caste quality it percieves. But then it can still lose. I got the impression that SPEAR's superiority is more because it has a good 'tsume solver' which sometimes sees very deep mates, that that its positional eval really helps.
User avatar
hgm
Posts: 27790
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Shogi

Post by hgm »

BTW, I just sent a WinBoard package to Takeshi Ito, with the latest Lima (I used the 64-bit popcount version; I assume they will use modern computers) and Shokidoki. It still includes the old TJshogi5x5 and Nebiyu. I don't know if Daniel has registered for the tourney.