WinBoard, exotic version

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

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

Re: WinBoard, exotic version

Post by hgm »

Daniel Shawul wrote:Edit1: Yes this is very serious. It happens with pawns and other pieces too. The winboard native one-click move should be completely turned off when engine has its own.
The intention was that the routine OnlyMove in WB would always return false when legality-checking was off (which is also a necessary requirement for the acceptation of click commands), but apparently this was not the cas. (Which was a bug in itself, making spurious 'only moves' in variants that have to be played with legality-checking off,unless you turned it off.)
Edit2: Nebiyu problem: When one-click was off, unambigious moves were not highlighted in nebiyu , so I fixed so that it will send a highlight even when sending clicks. It is uploaded.
Indeed, the engine should not assume its click commands are obeyed. WinBoard does suppress sending of lift and put commands in response to clicks emulated by click commands, so the engine can safely keep reacting to them at all times without funny effects during one-click moving.
Edit3: Winboard one-click problem checkers. Square a1 does not trigger a lift, so one-click doesn't work. But I do get a put even though there were no lifts. I think the problem is probably because a1=0 in your implementation. If I click elsewhere first and click again it works.
...
I can replicate this problem on other games too. One-click move not working the first time, but it does the second time.
I could not reproduce this so far, but I did not really test in Checkers. Clicking Ra1 in variant normal does cause the modified Fairy-Max to highlight some squares. It could be that this problem was related to the one-click problem above. (In Checkes the Pawn on a1 has only one move, and so has La1 in Shogi.)

New version uploaded (which should also fix the FEN-copy problem; the buffer in PositionToFEN was only 128 char...).
User avatar
hgm
Posts: 27794
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: WinBoard, exotic version

Post by hgm »

Some remarks about Shogi in NebiyuAlien:

1) Shogi only needs holdings size 7, because the King cannot be captured.
2) You use Queen for Gold, and Elephant for Lance, but normally WinBoard uses the Wazir symbol (10th) for Gold and the Spear symbol (19th) for Lance.
3) It is not clear to me how to enter promotions. When I click a 6th-rank white Pawn it does not one-click move, so apparently Nebiyu knows that there is a promotion choice, but when I make the move by hand, the Pawn does not promote, and when I type a move suffixed by =G, it refuses to parse. When I advance the Pawn to 9th rank, Nebiyu refuses the move, which WB suffixed with =G.

A more general problem: it is nice NebiyuAlien can play all these variants, but when I for instance would want to have it play Shogi against a Shogi engine, (e.g. Shokidoki), it cannot be done, because Nebiyu needs to play variant alien, and the Shokidoi needs to play variant shogi. I suppose the same applies to Checkers, etc. It would be nice if this could be solved.

Would it for instance be possible to let NebiyuAlien say that it does play variants shogi, checkers, 10x10+0_checkers, spartan, gothic, capalanca, makruk etc., and then on reception of (say) variant shogi automatically select shogi. I.e. make the command variant atomic equivalent to

option variant 8x8+0_atomic
new
variant alien


This would have the advantage that the variants WinBoard knows can be selected normally from the New Variant menu, that they can be played against dedicated engines, and that legality testing can be kept on. (For Shogi this might require some massaging of the move format in Nebiyu, w.r.t the promotion suffixes + and =.)
Daniel Shawul
Posts: 4185
Joined: Tue Mar 14, 2006 11:34 am
Location: Ethiopia

Re: WinBoard, exotic version

Post by Daniel Shawul »

I just tested it and all of the problems are gone now.
Yes the checkers problem was a side effect of the one-click problem.
User avatar
hgm
Posts: 27794
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: WinBoard, exotic version

Post by hgm »

Another small issue, this time with NebiyuChess. In variant grand you should use 10x10+2 rather than 10x10+0 in the setup command, because WinBoard uses holdings in that variant for dsplaying the available promotion choices to the user. And to make the choice, the user would have to click on one of the pieces there, which he cannot do if they are not displayed.

I noticed that NebiyuChess does react to the variant command, but also has an option 'variant'. Under what conditions will the latter be obeyed. E.g., how would I have to play Jetan? Fairy-Max has a similar option, that determines what it plays when WinBoard selects variant fairy. But in NebiyuChess fairy is not amongst the selectable variants.
Daniel Shawul
Posts: 4185
Joined: Tue Mar 14, 2006 11:34 am
Location: Ethiopia

Re: WinBoard, exotic version

Post by Daniel Shawul »

Some remarks about Shogi in NebiyuAlien:

1) Shogi only needs holdings size 7, because the King cannot be captured.
I calculate the holdings size from the number of black/white pieces by min(8,n/2-1) since shogi had many promotion pieces 8 was selected. I guess I can make the maximum 7. Is it also the same for crazy house? OR why calculate anyway, I will just let the game creator set it from the ini.
2) You use Queen for Gold, and Elephant for Lance, but normally WinBoard uses the Wazir symbol (10th) for Gold and the Spear symbol (19th) for Lance.
Luckily I can change it from alien.ini. i am sure I selected the promoted pieces randomly too. Here is the game file so you can help me change it.

Code: Select all

variant shogi
9 9
.*PpKkGgSsRrBbNnLlUuOoHhTtDdIi
lnsgkgsnl/1r5b1/ppppppppp/9/9/9/PPPPPPPPP/1B5R1/LNSGKGSNL[-] w - - 0 1

#PNBRQFEACWMOHIJGDVLSUKpnbrqfeacwmohijgdvlsuk
 PNBRGSL..UOITDH......Kpnbrgsl..uoitdh......k

P  100  wfuhyo
p  100  bfuhyo
K 5000  king
k 5000  king
G  600  wgoldgeneral
g  600  bgoldgeneral
S  500  wsilvergeneral
s  500  bsilvergeneral
R  900  rook
r  900  rook
B  800  bishop
b  800  bishop
N  400  wkeima
n  400  bkeima
L  300  wlance
l  300  blance
U  600  wgoldgeneral
u  600  bgoldgeneral
O 1200  dragon
o 1200  dragon
H 1200  dragonhorse
h 1200  dragonhorse
T  600  wgoldgeneral
t  600  bgoldgeneral
D  600  wgoldgeneral
d  600  bgoldgeneral
I  600  wgoldgeneral
i  600  bgoldgeneral
18 7 9 12
P 1 I
p 1 i
L 1 D
l 1 d
N 1 T
n 1 t
S 1 U
s 1 u
R 1 O
r 1 o
B 1 H
b 1 h
109 2

3) It is not clear to me how to enter promotions. When I click a 6th-rank white Pawn it does not one-click move, so apparently Nebiyu knows that there is a promotion choice, but when I make the move by hand, the Pawn does not promote, and when I type a move suffixed by =G, it refuses to parse. When I advance the Pawn to 9th rank, Nebiyu refuses the move, which WB suffixed with =G.
probabaly because all the weird promotion letters I use above.
A more general problem: it is nice NebiyuAlien can play all these variants, but when I for instance would want to have it play Shogi against a Shogi engine, (e.g. Shokidoki), it cannot be done, because Nebiyu needs to play variant alien, and the Shokidoi needs to play variant shogi. I suppose the same applies to Checkers, etc. It would be nice if this could be solved.

Would it for instance be possible to let NebiyuAlien say that it does play variants shogi, checkers, 10x10+0_checkers, spartan, gothic, capalanca, makruk etc., and then on reception of (say) variant shogi automatically select shogi. I.e. make the command variant atomic equivalent to

option variant 8x8+0_atomic
new
variant alien

This would have the advantage that the variants WinBoard knows can be selected normally from the New Variant menu, that they can be played against dedicated engines, and that legality testing can be kept on. (For Shogi this might require some massaging of the move format in Nebiyu, w.r.t the promotion suffixes + and =.)
That is great. I don't remember the reason why we chose to use engine combo box instead of registering the variants to winboard. I will send all the games in the alien.ini file to winboard at startup and it can accept those games it likes and reject the rest. OR I didn't test it but it might work as it is!! Becuase "option variant atomic" is equivalent to "variant atomic" to the nebiyu winboard parser.
Daniel Shawul
Posts: 4185
Joined: Tue Mar 14, 2006 11:34 am
Location: Ethiopia

Re: WinBoard, exotic version

Post by Daniel Shawul »

Another small issue, this time with NebiyuChess. In variant grand you should use 10x10+2 rather than 10x10+0 in the setup command, because WinBoard uses holdings in that variant for dsplaying the available promotion choices to the user. And to make the choice, the user would have to click on one of the pieces there, which he cannot do if they are not displayed.
I will definately make holding size user selectable for the alien version as this can not be calculated.
I noticed that NebiyuChess does react to the variant command, but also has an option 'variant'. Under what conditions will the latter be obeyed. E.g., how would I have to play Jetan? Fairy-Max has a similar option, that determines what it plays when WinBoard selects variant fairy. But in NebiyuChess fairy is not amongst the selectable variants.
Yes. There is only a slight difference
"option variant shogi" -> selects the variant but it does not send "setup" to winboard.
"variant shogi" -> does as above and also sends setup.
I think if the other engine sends setup it should play alright, because nebiyu is internally prepared to play the game.

Do you think it is a bad idea? The reason why I did it like that was because f.i I have GrandChess both as an alien and native version. For the alien it had to be selected from the combo box but for the native it had to be selected from winboard variant list. The two versions are in separate exes. (NebiyChess and NebiyuAlien)
Shogi is exclusively alien.
Rein Halbersma
Posts: 741
Joined: Tue May 22, 2007 11:13 am

Re: WinBoard, exotic version

Post by Rein Halbersma »

Daniel Shawul wrote:
ust for your convenience, see below for the impact of duplicate capture removal. The column "leafs" is the one to watch (I use quasi-UCI output for my perft routine, I use hashing with full positions as keys, and I count nps the same as during the search, so not equal to leafs per second). The difference for the initial position is tiny, but it is standard practice for international draughts. The reason? Some people have constructed positions in which a king can capture 14 men in >500 different ways. This will crash a program with fixed-size move list!
Oh that is serious then. My move list size is at 532 currently. I could not think of an easy way to check for duplicates at the time I implemented it. For captures of length 4, I may have to check 4! permutation max. Now that I know it will crash my program, I will dig in a little bit.

Btw is there a checkers tournament that I can join my program in? I would love to get my butt kicked .

Thanks
The record number of moves found so far is 530. These positions will never occur in games. During games, I have a move list of 128 moves. Even with all edge and corner squares covered with kings, the number of legal moves cannot exceed this.

Duplicate checking is very easy and cheap.

When you have finished a particular capture, you add it to the move list. If the current move list has 2 or more elements, and if the number of captured pieces of the current capture is 4 or more (and this is a very strong pre-condition), then you simply do a linear search over the move stack and check whether the last move is unique. In my program I simply call an STL find routine:

Code: Select all

// specialization for move generation without duplicate capture checking
bool tree&#58;&#58;node&#58;&#58;non_unique_top&#40;const Stack& stack, Int2Type<true>)
&#123;
        return std&#58;&#58;find&#40;stack.begin&#40;), stack.end&#40;), top&#40;stack&#41;) != &#40;stack.end&#40;) - 1&#41;;
&#125;
If this function returns <true>, then I simply pop() the move stack (i.e. decrement the counter of the move stack) and the duplicate is removed. During profiling, this never exceeds 0.1% of total resources.
Rein Halbersma
Posts: 741
Joined: Tue May 22, 2007 11:13 am

Re: WinBoard, exotic version

Post by Rein Halbersma »

Daniel Shawul wrote: Btw is there a checkers tournament that I can join my program in? I would love to get my butt kicked .

Thanks
There are 2 tournaments for 10x10 computer draughts every year: the Dutch and the French Open. This year, there is also the Computer Olympiad in Tilburg, the Netherlands, so there will probably quite a few Dutch entries. Not sure if you will go there with your chess engine or not.

Once I get around to finish hooking up my program to WinBoard, we can have a match for sure!
User avatar
hgm
Posts: 27794
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: WinBoard, exotic version

Post by hgm »

Daniel Shawul wrote:That is great. I don't remember the reason why we chose to use engine combo box instead of registering the variants to winboard. I will send all the games in the alien.ini file to winboard at startup and it can accept those games it likes and reject the rest.
Yes, this isgood practice. WinBoard does not care if there are variants there it does not know. Beware not to prefix variants with board size when you use the standard board size. WinBoard onlyuses prefixes for non-standard board sizes. So it would probably not recognize 8x8+0_spartan when it is looking for spartan.
OR I didn't test it but it might work as it is!! Becuase "option variant atomic" is equivalent to "variant atomic" to the nebiyu winboard parser.
This could be a bit dangerous. Officially a 'new' command swicthes the engine back to normal, so WB never follows it up with 'variant normal'. So you migh miss a change back to normal requested by the user through the New Variant dialog if you don't make that switch automatically on 'new'. But if you do make that switch, the user would have to use the Engine Settings combobox for every new game, and that is also undesirable.

You would want the combobox setting to have some persistence, surviving (new, variant) combinations as long as you stay in the same variant. So in Fairy-Max I made it such that the combobox setting is permanent (until the user changes it), but is only used when WB sends 'variant fairy'. Then it can switch back to normal on new, and to other explicitly specified variants, but when the user later returns to variant fairy, he will again get the setting from the combo-box.
Daniel Shawul
Posts: 4185
Joined: Tue Mar 14, 2006 11:34 am
Location: Ethiopia

Re: WinBoard, exotic version

Post by Daniel Shawul »

I am trying to send a variant with board size and name only like:

Code: Select all

feature variants="shogi,crazyhouse,atomic,ultima,normal,courier,capablanca,gothic,
grand,makruk,shatranj,knightmate,berolina,spartan,coordinatorchess,immobilizerchess,withdrawerchess,longleaperchess,advancerchess,pushmepullyuschess,
9x9+7_shogi,8x8+5_crazyhouse,8x8+0_atomic,8x8+0_ultima,8x8+0_normal,12x8+0_courier,10x8+0_capablanca,10x8+0_gothic,10x10+2_grand,8x8+0_makruk,
8x8+0_shatranj,8x8+0_knightmate,8x8+0_berolina,8x8+0_spartan,10x8+0_coordinatorchess,
10x8+0_immobilizerchess,10x8+0_withdrawerchess,10x8+0_longleaperchess,10x8+0_advancerchess,10x8+0_pushmepullyuschess"
But it keeps crashing. Btw it seems that the "variant alien" is not needed anymore. You call it "variant fairy" right?

I was sending 9x9+7_alien, 8x8+5_alien etc... just to tell it which board size it supports. May be I should attach this to the above string too just incase winboard rejects the variant.

I changed Nebiyu to get the holding space size from alien.ini. So this can
be specified when there are no holdings in the game.
I changed to 10x10+2_grand but winboard rejects it in the normal version.