Makruk engines and rating list

Discussion of anything and everything relating to chess playing software and machines.

Moderators: hgm, Rebel, chrisw

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

Re: Makruk engines and rating list

Post by hgm »

As to implementing the counts in WinBoard, some things are still not clear to me:

For one, I found this description on chessvariants.com, which deviates from Wikipedia. According to the latter, KBNNQK would give you 44 - 6 = 38 moves (one B, no R). All sources agree that KNNQK would be 32 - 5 = 27 moves. In the chessvariants.com description KBNNQK would also be 32 - 6 = 26 moves, though, because 2 Knights has priority over 1 Bishop. I tend to believe the latter, as it makes little sense to award more moves when you get an extra B.

It also confuses me that you count up, rather than down. This makes that the count that has to be compared occurs at the end, when the material composition might have been changed compared to the beginning. So should it be compared to the material present when the count is reached, or when you started counting? When you would have counted down, you would start with the number corresponding to the composition at that moment, and it would be unambiguous what "not restarting the counting" meant.

The Wikipedia says counting restarts when you bare the King, if you were already counting because of absence of Pawns, and makes it sound like this is mandatory. The other description suggests it is optional, however. I can imagine you often would restart the counting, because for many material combinations with bare King the number of allowed moves is way lower than the 64 you get when there are no Paws.
Ferdy
Posts: 4833
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: Makruk engines and rating list

Post by Ferdy »

hgm wrote:As to implementing the counts in WinBoard, some things are still not clear to me:

For one, I found this description on chessvariants.com, which deviates from Wikipedia. According to the latter, KBNNQK would give you 44 - 6 = 38 moves (one B, no R). All sources agree that KNNQK would be 32 - 5 = 27 moves. In the chessvariants.com description KBNNQK would also be 32 - 6 = 26 moves, though, because 2 Knights has priority over 1 Bishop. I tend to believe the latter, as it makes little sense to award more moves when you get an extra B.
From this
http://ancientchess.com/page/play-makruk.htm
it should be 2 knights first before 1 bishop and I believe this is right. The count must be in ascending order like:
2r = 8
1r = 16
2b = 22
2n = 32
1b = 44
others = 64

In wiki
https://en.wikipedia.org/wiki/Makruk
the 32 and 44 were mixed up, but the statements are correct.
hgm wrote:It also confuses me that you count up, rather than down. This makes that the count that has to be compared occurs at the end, when the material composition might have been changed compared to the beginning. So should it be compared to the material present when the count is reached, or when you started counting? When you would have counted down, you would start with the number corresponding to the composition at that moment, and it would be unambiguous what "not restarting the counting" meant.
I don't really understand what you are implying. But it is clear in the rule that move count is based on the current material on the board when you start the calculation.

Code: Select all

Example 1:
krrk black to move (last move of white captures the last piece of black), white has 2 rooks black has bare king.
move_count = 8 (because of 2r)
pieces = k+r+r+k = 4
White should mate black in 8-4 = 4 moves or less to win.
Black should not be mated in 5 moves to draw.

Code: Select all

Example 2:
krrkr black to move (the last move of white captures the last pawn of black).
move_count = 64
White should mate black in 64 moves or less to win.
[moves were made later ...]
and now it is white to move and its his 64th move, and black still was not mated meaning white has 1 move remaining to mate and win. And there is no move of white that can mate black in 1 move, so he captures the rook of black and black has now a bare king. The question is should black restart the counting? If black restart the counting because of bare king, white would need to mate black again in 8-4 = moves. If black is clever he should not restart the counting because the 64th move of white from previous counting session was not a mate.
I was wrong of subtracting the material always (to determine the number of moves to mate) in my previous posts. The material is only subtracted when there is bare king. If only pawns are missing and there is no bare king, then the 64 move count is in effect, the stronger side should mate his opp in 64 moves or less to win and not 64 minus pieces_remaining.

In wiki:
When neither side has any pawns left, mate must be achieved in 64 moves. The disadvantaged player does the counting, and may at any time choose to stop counting. If the disadvantaged side checkmates the advantage side and did not stop counting, the game is declared a draw.
I am not sure how the engine would communicate with the gui that it starts counting and then later intends to stop counting because the materially stronger side is going to be mated.
hgm wrote:The Wikipedia says counting restarts when you bare the King, if you were already counting because of absence of Pawns, and makes it sound like this is mandatory. The other description suggests it is optional, however. I can imagine you often would restart the counting, because for many material combinations with bare King the number of allowed moves is way lower than the 64 you get when there are no Paws.
I believe this is optional, the idea is, the losing side would restart counting if it would result to a lower count than the updated count from previous calculation.
User avatar
hgm
Posts: 27790
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Makruk engines and rating list

Post by hgm »

Ferdy wrote: In wiki:
When neither side has any pawns left, mate must be achieved in 64 moves. The disadvantaged player does the counting, and may at any time choose to stop counting. If the disadvantaged side checkmates the advantage side and did not stop counting, the game is declared a draw.
I am not sure how the engine would communicate with the gui that it starts counting and then later intends to stop counting because the materially stronger side is going to be mated.
I don't understand the usefulness of this rule. As I understand it, you count on your own moves. So when I can checkmate my opponent in one, I obviously would not count on that move, right? If threaten mate (in 1), but he has a defense, but I hope he will not see it (which will never occure with an engine anyway), I can still count that move, (to not alert the opponent to the mate threat) and stop counting when he blunders for the actual mating move. So what is the point of the rule? It would only make sense if the checkmate=draw rule applied for one or more moves after you stopped counting. The strong site can never benefit from this rule, because it cannot afford to expose himself to mate even when the opponent is counting, as he is playing for a win.
I believe this is optional, the idea is, the losing side would restart counting if it would result to a lower count than the updated count from previous calculation.
OK, then I will implement it that way. Since the material when you start counting determines the final count, and you count durig your own turn, it becomes important to know whether you count before or after your move. E.g. in KRRKR, if white would trade Rooks, black would call 'five' while he recaptures the Rook, so before his move it is KRRK, and after it KRK. Will the draw be claimed on the count of 9 or the count of 17, now? In the former case it would almost certainly be draw, because it would only leave 4 moves to force mate in KRK. This would likely affect how engines have to play KRRKR.

Anyway, it seems I can use the following algorithm for draw adjudication:

1) set N=0
2) determine the material composition in the current position
3) determine a (ply) count from this (if bare King or pawnless)
4) add the number of ply to the precedig capture to N
5) if N exceeds the count determined in (3), adjudicate a draw
6) count the material before the capture
7) continue with (3)
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Makruk engines and rating list

Post by Evert »

Ferdy wrote:I am not sure how the engine would communicate with the gui that it starts counting and then later intends to stop counting because the materially stronger side is going to be mated.
I think this is an example of a rule that does not translate well to computer play. It simply adds complications for human games that do nothing for computer games. You can assume that if the engine sees it can deliver mate, it would stop counting. No need for it to communicate anything.
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Makruk engines and rating list

Post by Evert »

hgm wrote: OK, then I will implement it that way. Since the material when you start counting determines the final count, and you count durig your own turn, it becomes important to know whether you count before or after your move.
I always interpreted it as before (although I update the count after the move; this affects the check).
Anyway, it seems I can use the following algorithm for draw adjudication:

1) set N=0
2) determine the material composition in the current position
3) determine a (ply) count from this (if bare King or pawnless)
4) add the number of ply to the precedig capture to N
5) if N exceeds the count determined in (3), adjudicate a draw
6) count the material before the capture
7) continue with (3)
I use the following algorithm:

1. If the last move was a capture: determine the current move-count limit.
2. If I was counting, determine if I can now claim a draw.
3. If I can (re)start the count, do so if it is to my advantage.
4. If there is an on-going count, increase the counter.
User avatar
hgm
Posts: 27790
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Makruk engines and rating list

Post by hgm »

I agree your algorithm is the obvious one, but it supposes the existence of an incrementally updated counter and a maximum count as part of the game state. Which WinBoard does not have. And it would be rather error-prone to add it (as game states are copied in many places). It does keep an e.p.-rights variable as part of the game state, though, which I generalized by also giving it distinguishable values for moves that are not Pawn double-pushes. For 50-move adjudication it runs through the game history examining this variable every time. (Highly inefficient, of course, but in GUIs this is not really in issue.) This is why I conceived the method I described above.

I guess to capture the counting aspect of the game state in a FEN, the best method would be to report the number of ply still to go before a claim can be made, in the reversible-move counter field.
Ferdy
Posts: 4833
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: Makruk engines and rating list

Post by Ferdy »

hgm wrote:
Ferdy wrote: In wiki:
When neither side has any pawns left, mate must be achieved in 64 moves. The disadvantaged player does the counting, and may at any time choose to stop counting. If the disadvantaged side checkmates the advantage side and did not stop counting, the game is declared a draw.
I am not sure how the engine would communicate with the gui that it starts counting and then later intends to stop counting because the materially stronger side is going to be mated.
I don't understand the usefulness of this rule. As I understand it, you count on your own moves. So when I can checkmate my opponent in one, I obviously would not count on that move, right? If threaten mate (in 1), but he has a defense, but I hope he will not see it (which will never occure with an engine anyway), I can still count that move, (to not alert the opponent to the mate threat) and stop counting when he blunders for the actual mating move. So what is the point of the rule? It would only make sense if the checkmate=draw rule applied for one or more moves after you stopped counting. The strong site can never benefit from this rule, because it cannot afford to expose himself to mate even when the opponent is counting, as he is playing for a win.
When someone is in the state of counting his intention is to draw and not to win. When I played in internet server, there are buttons of whether you will start counting and stop counting.
http://www.playok.com/en/makruk/
hgm wrote:
I believe this is optional, the idea is, the losing side would restart counting if it would result to a lower count than the updated count from previous calculation.
OK, then I will implement it that way. Since the material when you start counting determines the final count, and you count durig your own turn, it becomes important to know whether you count before or after your move. E.g. in KRRKR, if white would trade Rooks, black would call 'five' while he recaptures the Rook, so before his move it is KRRK, and after it KRK. Will the draw be claimed on the count of 9 or the count of 17, now? In the former case it would almost certainly be draw, because it would only leave 4 moves to force mate in KRK. This would likely affect how engines have to play KRRKR.
It can be claimed in the count of krrk = 8-4 if black wants to, or black will capture first the white rook and start counting from there which is krk = 16-3.
User avatar
hgm
Posts: 27790
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Makruk engines and rating list

Post by hgm »

Ferdy wrote:When someone is in the state of counting his intention is to draw and not to win. When I played in internet server, there are buttons of whether you will start counting and stop counting.
http://www.playok.com/en/makruk/
So when an opponent that has a winning advantage blunders, and exposes himself to mate-in-1... Can you then press the button 'Stop Counting' and checkmate him? If so, the rule only serves to penalize people who forget to press the button before moving. A mistake engines would never make.
It can be claimed in the count of krrk = 8-4 if black wants to, or black will capture first the white rook and start counting from there which is krk = 16-3.
Well, black would never do the latter; the allowed count can only go up by his move, so he would always base it on the position before his move when this makes a difference. This then is a case where the engine must be aware of the counting rules, as the KRK mate is likely to be within its horizon, but also likely to require more than 4 moves. So it must somehow be discouraged from going for such a mate.

[Edit] Does this mean a player can already start counting 'one' on the move that captures the last Pawn?
Ferdy
Posts: 4833
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: Makruk engines and rating list

Post by Ferdy »

hgm wrote:
Ferdy wrote:When someone is in the state of counting his intention is to draw and not to win. When I played in internet server, there are buttons of whether you will start counting and stop counting.
http://www.playok.com/en/makruk/
So when an opponent that has a winning advantage blunders, and exposes himself to mate-in-1... Can you then press the button 'Stop Counting' and checkmate him? If so, the rule only serves to penalize people who forget to press the button before moving. A mistake engines would never make.
The button to stop is shown, so the user at any time may stop counting. Probably the reason why a player need to stop counting when he wants to win is because the other player may have the chance to start counting himself to draw, situation is reversed.
Ferdy
Posts: 4833
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: Makruk engines and rating list

Post by Ferdy »

hgm wrote:[Edit] Does this mean a player can already start counting 'one' on the move that captures the last Pawn?
No as there is still a pawn. That capture move has to be executed first.

Code: Select all

I. The Board’s Honor Rule

If there are no unpromoted pawns on the board, and you are at a distinct disadvantage, you may begin counting your moves aloud up to 64 (the number of squares on the board). If you are able to make the 65th move and you haven’t been checkmated, the game is a draw.