Xboard / highlight promotion issue

Discussion of chess software programming and technical issues.

Moderator: Ras

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

Xboard / highlight promotion issue

Post by Evert »

Debugging an issue with promotions in Sittuyin in SjaakII, I ran into some issues with XBoard.

Sittuyin allows pawns to promote without moving. SjaakII sends these as "e5e5f"* (for a pawn on e5). This seems to work ok.
The issues arise when trying to enter such moves with the mouse. Clicking the pawn to promote, a blue disk appears over the pawn, indicating a singular promotion choice for that square. It sends "choice f" in response to "put" and Xboard issues an "illegal move: e5xe5" claim, apparently after sending "e5e5" to the engine (without the promotion suffix).
Changing the code so a purple disk appears over the pawn, the normal drag-promotion choice is activated, with ferz the only option. This is accepted, and XBoard sends "e5e5f" to the engine. However, XBoard still considers the piece a pawn, as can be checked in the displayed position as well as the FEN it produces.

Is there a bug here, or is there something I'm missing?

* the issue I fixed is actually that SjaakII would send these as "@@@@", so the current release is faulty in this sense.
User avatar
hgm
Posts: 28458
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Xboard / highlight promotion issue

Post by hgm »

What an awful case. I will have to checkout what happens here. Null moves are normally not entered by making a to-click on the from-square (except if another square has already been entered in the course of a rifle capture). Without engine highlight this would just be a deselection of the piece. With an engine-applied highlight I guess this is overruled, but the later processing wasnot written at allwith this possibility in mind.
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Xboard / highlight promotion issue

Post by Evert »

hgm wrote:What an awful case. I will have to checkout what happens here. Null moves are normally not entered by making a to-click on the from-square (except if another square has already been entered in the course of a rifle capture). Without engine highlight this would just be a deselection of the piece. With an engine-applied highlight I guess this is overruled, but the later processing wasnot written at allwith this possibility in mind.
The odd thing is that I think this used to work at some point, but possibly as an unintended side-effect. Note that the move in question is not really a null-move, since it has a side-effect (promotion).

Relevant debug logs:

With blue highlight:
4618 >first : new
random
4618 >first : variant sittuyin
4618 >first : level 40 0:10 0
4618 >first : post
4618 >first : hard
4618 >first : easy
4618 >first : ping 2
Impossible move , type = 0
4618 >first : force
write FEN 50-move: 1 0 0
e0. p=-6
4618 >first : setboard 2r2r2/kn1ns1s1/2f1p1pp/ppppP3/6PP/PPPPS1SN/5NK1/5RR1[-] w - - 1 1
EditPosDone
4719 <first : # New game 'Chess'
4719 <first : # New game 'Sittuyin'
4719 <first : setup (PN.R.F....SKpn.r.f....sk) 8x8+6_bughouse 8/8/4pppp/pppp4/4PPPP/PPPP4/8/8[KFRRSSNNkfrrssnn] w - - 0 1
recognized 'bughouse' (-1) as variant sittuyin
4719 <first : piece N& Nj@3
4719 <first : piece S& FfWj@3
4719 <first : piece F& Fjb@3
4719 <first : piece R& R@1
4719 <first : piece K& Kj@3
4719 <first : piece P& fmWfcFj@3
4719 <first : pong 2
7059 >first : lift e5
7062 <first : highlight 8/8/8/4B3/8/8/8/8
7064 <first : choice F
11456 >first : put e5
11457 >first : e5e5
11525 <first : choice F
11525 <first : Error (Illegal move or unknown command): e5e5
With magenta highlight:
4053 >first : new
random
4053 >first : variant sittuyin
4053 >first : level 40 0:10 0
4053 >first : post
4053 >first : hard
4053 >first : easy
4053 >first : ping 2
Impossible move , type = 0
4053 >first : force
write FEN 50-move: 1 0 0
e0. p=-6
4053 >first : setboard 2r2r2/kn1ns1s1/2f1p1pp/ppppP3/6PP/PPPPS1SN/5NK1/5RR1[-] w - - 1 1
EditPosDone
4128 <first : # New game 'Chess'
4128 <first : # New game 'Sittuyin'
4128 <first : setup (PN.R.F....SKpn.r.f....sk) 8x8+6_bughouse 8/8/4pppp/pppp4/4PPPP/PPPP4/8/8[KFRRSSNNkfrrssnn] w - - 0 1
recognized 'bughouse' (-1) as variant sittuyin
4128 <first : piece N& Nj@3
4128 <first : piece S& FfWj@3
4128 <first : piece F& Fjb@3
4128 <first : piece R& R@1
4128 <first : piece K& Kj@3
4128 <first : piece P& fmWfcFj@3
4128 <first : pong 2
6371 >first : lift e5
6374 <first : highlight 8/8/8/4M3/8/8/8/8
6376 <first : choice F
7881 >first : put e5
7885 <first : choice F
9352 >first : put e5
9353 >first : e5e5f
9357 <first : choice F
but the Ferz changes back to pawn in XBoard's board representation (output FEN 2r2r2/kn1ns1s1/2f1p1pp/ppppP3/6PP/PPPPS1SN/5NK1/5RR1[-] b - - 0 1)

EDIT: note that the latest release of SjaakII will incorrectly reject "e5e5f"; I suppose injecting the feature san=1 will work though.
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Xboard / highlight promotion issue

Post by Evert »

A separate minor issue: xboard generates "lift" commands for off-the-board squares (holdings). I guess it either shouldn't do that, or it should be a defined part of the protocol to allow for specification of piece-dependent drop zones. Figuring out what rank corresponds to what piece type will be a bit of a pain though (since SjaakII doesn't have the same ordering as XBoard; the first is arbitrary and in a sense doesn't even know about the second).
User avatar
hgm
Posts: 28458
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Xboard / highlight promotion issue

Post by hgm »

Good point. I think limiting the drop zone is a useful application. But a more logical way to relay that to the engine would be as something like "lift N@".
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Xboard / highlight promotion issue

Post by Evert »

hgm wrote:Good point. I think limiting the drop zone is a useful application. But a more logical way to relay that to the engine would be as something like "lift N@".
Makes sense.
By the way, is there a way to represent "lift" moves? I think at one point it was considered that these could be represented by "@@square" (dropping "@" on the square of the piece to be lifted).

Not that I want to derail my own thread...
User avatar
hgm
Posts: 28458
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Xboard / highlight promotion issue

Post by hgm »

The current parser does not recognize that.

Typing d1d3=A in the FIDE starting position makes the Queen disappear, however! :shock:
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Xboard / highlight promotion issue

Post by Evert »

So, is there a possibility of fixing this?
I'd be happy to give it a shot myself (if I can find the time), if I can get a pointer for where in the source to look (and some clue for which is the current source repository).
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Xboard / highlight promotion issue

Post by Evert »

I keep running into strange issues with this.

Apparently the promotion rules in Sittuyin are a bit different: promotion is allowed if the pawn is in the promotion zone. It is done by replacing the pawn with a Ferz. The Ferz is then allowed (but not required) to make a quiet move as part of the same move.
The effect is that the pawn either stays where it is and turns into a Ferz, or it moves as a Ferz and promotes in the same move.

In addition, if there is only a single pawn remaining, the promotion zone expands to the entire board.

I'm trying to get this to work in XBoard, but it appears to... resist my efforts. I'm using the following position:
[d]8/4P3/6k1/8/1p1K4/8/8/8 w - - 0 1

Allowed pawn moves: e7-e8, e7-d8F, e7-f8F, e7-d6F, e7-f6F, e7-e7F
XBoard automatically upgrades e7-e8 to a promotion move (which is rejected). I suppose this is a side-effect of using the regular pawn, which is a piece with side-effects. I tried picking a piece without side-effects instead, but now nothing seems to work.

Picking another piece (B) without side effects:

Code: Select all

2589 >first : ping 2
Impossible move , type = 0
2589 >first : force
write FEN 50-move: 0 0 0
e0. p=-6
2589 >first : setboard 8/4P3/6k1/8/1p1K4/8/8/8[-] w - - 0 1
EditPosDone
2685 <first : # New game 'Chess'
2685 <first : # New game 'Sittuyin'
2685 <first : setup (.NPR.F....SKpn.r.f....sk) 8x8+6_bughouse 8/8/4pppp/pppp4/4PPPP/PPPP4/8/8[KFRRSSNNkfrrssnn] w - - 0 1
2685 <first : piece N& N@3
2685 <first : piece S& FfW@3
2685 <first : piece F& Fb@3
2685 <first : piece R& R@1
2685 <first : piece K& K@3
2685 <first : piece P& fmWfcF@3
2685 <first : pong 2
3844 >first : lift e7
3845 <first : highlight 3BYB2/4B3/3B1B2/8/8/8/8/8
3847 <first : choice F
6214 >first : put e8
6215 >first : e7e8
BackwardInner(0), current 1, forward 1
7695 >first : undo
8805 >first : lift e7
8807 <first : highlight 3BYB2/4B3/3B1B2/8/8/8/8/8
8809 <first : choice F
9949 >first : put d8
9949 >first : e7d8
9958 <first : choice F
9958 <first : Error (Illegal move or unknown command): e7d8
GameEnds(29, xboard exit, 2)
With regular pawn:

Code: Select all

3993 >first : ping 2
Impossible move , type = 0
3993 >first : force
write FEN 50-move: 0 0 0
e0. p=-6
3993 >first : setboard 8/4P3/6k1/8/1p1K4/8/8/8[-] w - - 0 1
EditPosDone
4144 <first : # New game 'Chess'
4144 <first : # New game 'Sittuyin'
4144 <first : setup (PN.R.F....SKpn.r.f....sk) 8x8+6_bughouse 8/8/4pppp/pppp4/4PPPP/PPPP4/8/8[KFRRSSNNkfrrssnn] w - - 0 1
4144 <first : piece N& N@3
4144 <first : piece S& FfW@3
4144 <first : piece F& Fb@3
4144 <first : piece R& R@1
4144 <first : piece K& K@3
4144 <first : piece P& fmWfcF@3
4144 <first : pong 2
6204 >first : lift e7
6206 <first : highlight 3BYB2/4B3/3B1B2/8/8/8/8/8
6208 <first : choice F
9889 >first : put e8
10312 >first : put e8
10312 >first : e7e8f
10317 <first : Error (Illegal move or unknown command): e7e8f
GameEnds(29, xboard exit, 2)
13173 >first : quit
Questions:
1. Why is XBoard ignoring the promotion in the first example (the target square has a blue highlight)?
2. I think there is a way to get a "no-side effect" pawn (a piece that looks like a pawn but has no build-in side effects), where do I find that in the pieceToChar list?
3. Is there perhaps another way to make it respect the yellow highlight in the colour FEN (so it will not force the promotion)?
4. Perhaps I'm doing something wrong with the highlight/choice/lift/put sequence?