Makruk

Discussion of chess software programming and technical issues.

Moderator: Ras

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

Re: Makruk

Post by hgm »

Evert wrote:Yes, that probably would be helpful!
I was thinking that I could probably split the list in half (exploiting left/right symmetry), leaving some 500 positions and then go through them by hand in a not-quite random order (positions where the silver is checking the king first), but having a list of positions to toss out will certainly help there!
Can you PM me an e-mail address where I should send it? I have it in a format now where I just print indexes by concatenating square coordinates of wK, S, N and bK, where 02 = c1 etc.:

Code: Select all

 K S N K
02011200
02012100
12012100
26051507
27051507
27052607
05060007
05060107
05060207
05060307
05060407
05061007
05061107
...
Did you try a pair of tweaked bishops or a normal bishop+tweaked bishop?
If the dominant effect is the colour-binding, then a pair of normal bishops should be worth approximately the same as a bishop+tweaked bishop, or a pair of tweaked bishops. I would actually expect the difference in piece value to be worth approximately the same as (or perhaps half of) the bishop pair bonus. Your measurement seems to be in that ballpark.
I don't remember, but I almost always measure pieces in pairs, to get better signal to noise. So probably two tweaked Bishops against a B-pair. That would mean that the 33cP was what they got on top of sharing a B-pair bonus.
I was thinking whether I could use the difference in value between a ferz and a silver as a rough indication for what a "ferz-pair bonus" might be worth. Can't be the full story of course, since ferz+ferz should not be worth the same as ferz+silver.
Easier would probably be to measure like Ferz vd unlike Ferz. For Bishops this reproduces the B-pair bonus quite accurately. For Ferz the bonus is probably really small, though, as the Ferz itself is hardly worth anything (about 150 cP in FIDE context, measured by playing F-pair vs Knight).
Yes, that's exactly the sort of thing I see happening that needs to be avoided. I'm wondering whether it makes sense to base the "game phase" on the number of remaining pawns, but I haven't played around with that at all yet.
Note that when you don't have a material table with explicit trading gradients, the game phase often works as such. By increasing the end-game values of all pieces any imbalance will look larger in end-game evaluation, which will provide a drive towards advancing the game phase when ahead in material. If you would base the game phase on number of Pawns, advancing the game phase would mean trading Pawns, though. And this is probably exactly what you don't want.

When I had to express it in a formula I would say something like

gamePhase = whitePower + blackPower
evalWhitePOV = (2 - gamePhase/MAXPOWER)*(whiteMaterial - blackMaterial)
+ C * max(whitePower - blackPower, 0) * blackPawns
- C * max(blackPower - whitePower, 0) * whitePawns

is needed, where white/blackPower is some measure for tactical power. (E.g. like Fruit uses 6*nQ + 3*nR + nB + nN.) Ferz should probably not count at all in this power measurement. (If they do you would have to make sure that this doesn't bias you against promotion.) The last two terms bias you against trading Pawns when ahead in pieces. The first one encourages you to trade pieces when ahead, to advance game phase.
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Makruk

Post by Evert »

hgm wrote: Can you PM me an e-mail address where I should send it? I have it in a format now where I just print indexes by concatenating square coordinates of wK, S, N and bK, where 02 = c1 etc.:
Done!
I don't remember, but I almost always measure pieces in pairs, to get better signal to noise. So probably two tweaked Bishops against a B-pair. That would mean that the 33cP was what they got on top of sharing a B-pair bonus.
Ah, ok.
Easier would probably be to measure like Ferz vd unlike Ferz. For Bishops this reproduces the B-pair bonus quite accurately. For Ferz the bonus is probably really small, though, as the Ferz itself is hardly worth anything (about 150 cP in FIDE context, measured by playing F-pair vs Knight).
For sure.
I've actually scaled all the piece values to get more resolution for positional terms. If two pieces are so close in value it doesn't leave you a whole lot of room for small terms. Although I mainly did that in order to be able to mix in elephants as well (the worthless shatranj type).
Note that when you don't have a material table with explicit trading gradients, the game phase often works as such. By increasing the end-game values of all pieces any imbalance will look larger in end-game evaluation, which will provide a drive towards advancing the game phase when ahead in material. If you would base the game phase on number of Pawns, advancing the game phase would mean trading Pawns, though. And this is probably exactly what you don't want.
Good point.
However, some pieces would (could) have their value go down with game phase. I suspect most pieces in Makruk should (with the possible exception of the rook).
When I had to express it in a formula I would say something like

gamePhase = whitePower + blackPower
evalWhitePOV = (2 - gamePhase/MAXPOWER)*(whiteMaterial - blackMaterial)
+ C * max(whitePower - blackPower, 0) * blackPawns
- C * max(blackPower - whitePower, 0) * whitePawns

is needed, where white/blackPower is some measure for tactical power. (E.g. like Fruit uses 6*nQ + 3*nR + nB + nN.) Ferz should probably not count at all in this power measurement. (If they do you would have to make sure that this doesn't bias you against promotion.) The last two terms bias you against trading Pawns when ahead in pieces. The first one encourages you to trade pieces when ahead, to advance game phase.
Doesn't the last term slightly bias you against winning black pawns though (assuming C>0, but it should of course be small enough that it never dominates the first term)? Wouldn't it make more sense to award a bonus for having more pawns yourself?
User avatar
hgm
Posts: 28480
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Makruk

Post by hgm »

Why would Makruk pieces go down in value towards the end-game? I would only expect that for pieces like the Xiangqi Cannon, whose move explicitly depends on presence of other pieces. Of course a more precise approach would use

gamePhase/MAXPOWER * (whiteMaterialEG - blackMaterialEG) +
(1 - gamePhase/MAXPOWER) * (whiteMaterialOP - blackMaterialOP)

where you can set the EG and OP value of each piece separately. But in general an advantage is felt more when there is less material on the board, so I would expect all EG values to be larger than the corresponding OP values. If this would not be true for piece X, it means that you would create a bias against trading other piece material if your only advantages consisted of a piece X. Even an advantage of a Ferz seems huge if there is nothing else but Pawns. Of course you will have good Ferz / bad Ferz like with Bishops, but even a truly bad Ferz can stil be used to inflict zugzwangs. Furthermore Ferzes are worth so little that you can easily afford to sacrifice one for a Pawn to create a passer, and then promote that passer to get your Ferz back. Note that KPK always leads to promotion in Makruk, as there is no last-rank stalemate. When teaming up against a King in zugzwang K+F should be able to force it away from its Pawns, and then gobble up the latter.

But of course some pieces could go up in EG value faster than others.

Gobbling up Pawns when you lead in pieces is indeed made less attractive by the later terms. This is a logical consequence of the fact that you already take an advance on the fact that you plan to win them anyway. So there is no hurry, they cannot escape. This is completely analogous to giving a 7th-rank passer bonus in Chess. Such a bonus biases you against promoting.

Increasing the value of your own Pawns in stead would also bias you against Pawn trading, but it would also cause other effects, which are artifacts. E.g. I would be less inclined to 'trade' my Pawns for an opponent Ferz, while even when I promote them they would not give me anything better than a Ferz. It would also bias me against promoting my own Pawns, while there is little harm in doing that.

It is true that overdoing it could give opponent pawns an effective negative value. But this might not even be unrealistic. The more I am ahead, the more severe the counting rules will be when I would gobble up his Pawns. When a Rook or more ahead, I should rather let him keep his Pawns to avoid counting. Of course an effective negative Pawn value would increase his promotion gain, as the Ferz does not suffer.

I'd rather see his Pawn value drop to zero than see my own Pawn value rise to above that of a Ferz.
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Makruk

Post by Evert »

hgm wrote:Why would Makruk pieces go down in value towards the end-game? I would only expect that for pieces like the Xiangqi Cannon, whose move explicitly depends on presence of other pieces.
The cannon is obvious (although I can never make up my mind whether it should depend more on your own pieces or enemy pieces), as is the Xiangqi horse improving in the end game (because of better mobility, basically). My thinking for the Makruk pieces is different and has to do with how weak the minor pieces are. Admittedly I was mostly thinking of the ferzes here, but it seems to me that too many games get drawn because the advantage of the ferz is not enough after a lot of material has been exchanged. So if you're only up a ferz (or a ferz against a pawn), better not trade down. I guess that's really the main point, and dropping the value of the ferz with game phase is probably not the only way to do it.
This is completely analogous to giving a 7th-rank passer bonus in Chess. Such a bonus biases you against promoting.
Yes, I remember the fun I had when my passer bonus was accidentally set so high that the pawn+bonus was worth more than the queen. It became very difficult to win end games.
It is true that overdoing it could give opponent pawns an effective negative value. But this might not even be unrealistic. The more I am ahead, the more severe the counting rules will be when I would gobble up his Pawns. When a Rook or more ahead, I should rather let him keep his Pawns to avoid counting. Of course an effective negative Pawn value would increase his promotion gain, as the Ferz does not suffer.

I'd rather see his Pawn value drop to zero than see my own Pawn value rise to above that of a Ferz.
I haven't tackled that one yet, but I've been thinking that I could drop the material advantage severely (perhaps by half) in positions with counting. That would dissuade the program from seeking them out when ahead (and cause it to look for them when behind, which is useless if the counting is not actually implemented).

By the way, do you have an opinion on ASEAN chess? I've watched a few games and it looks like a broken version of Makruk to me. What speeds up the game in Makruk is that the pawns are advanced to begin with (basically a different solution to the problem with Shatranj that is solved by allowing pawns a double step) and that they promote very close to the front line of battle (rather than the back rank). This makes the game more dynamic. In ASEAN the pawns have to reach the back rank before they can promote, which makes promotion much more difficult and then when they finally get there your reward is a lousy ferz. It looks like a mistake to me.
User avatar
hgm
Posts: 28480
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Makruk

Post by hgm »

Evert wrote:The cannon is obvious (although I can never make up my mind whether it should depend more on your own pieces or enemy pieces), as is the Xiangqi horse improving in the end game (because of better mobility, basically).
Indeed. And Elephants and Advisers drop in value if there is nothing left to defend against. Material evaluation is pretty complex in Xiangqi.
My thinking for the Makruk pieces is different and has to do with how weak the minor pieces are. Admittedly I was mostly thinking of the ferzes here, but it seems to me that too many games get drawn because the advantage of the ferz is not enough after a lot of material has been exchanged. So if you're only up a ferz (or a ferz against a pawn), better not trade down. I guess that's really the main point, and dropping the value of the ferz with game phase is probably not the only way to do it.
Well, I tried a few games with Fairy-Max, F+6P vs 6P:
[d]4k3/8/ppp2ppp/8/8/PPP2PPP/8/3KQ3 w
The Pawns are toast, and typically it ends with 5 Ferzes against a bare King. (Fairy-Max of course then always draws this at 40/1 because the Ferzes then all cluster in the center, but it never has all Ferzes on the same color, so in principle it is an easy win. I must have a Makruk-adapted version somewhere that tests for bare King in the root and then multiplies its centralization score by 10, and that version should checkmate with 3F easily.)

So it seems a single Ferz is a decisive advantage, provided there are enough Pawns, and enough of them promote on the 'right' color. Like in Chess, games get drawish if there aren't enough Pawns. In Chess 'enough' is often one, because of the strong promotion and stronger pieces. You cannot afford it to promote, so you will have to sac a piece for it, and the remaining piece disadvantage then is likely losing even in the absence of Pawns. Only the advantage of a single minor, and the exceptional 2N are draws, and if we forget about the latter (because KNNKP might still be won, etc.), having a single Pawn will already be drawish when the opponent has a minor (and you don't already have a piece majority).

In Makruk this is a bit different, as KFFK, KFNK and KNNK are all draw, and even KFFFK can be draw because of color-binding. So you have to hang on to more Pawns, and in particular more Pawns of the right promotion color. The Pawns you need to eventually acquire a winning advantage after annihilating opponent Pawns and promoting your own are in jeopardy by opponent Ferzes, as the F-for-P trades do not increase your projected majority at all. In KFFPPPKFPP with like whithe F you might already have to devaluate with 3 Pawns, if two of them happen to promote on the color you already have, so that black only has to sac its Ferz for your last Pawn of the opposite color to achieve a draw.

Problem is that I don't know whether KF'FFFKF' (the primes indicating the color) is a win, or whether black can force the F'-for-F' trade for an insufficient-material draw. (I am pretty sure KF'FFFKF should be a win.) So even if you do manage to promote your Pawn to a Ferz of the missing color without it being sacrificed away for the defending Ferz, it might still not help if that defending Ferz is also of that color.

So keeping track of all Ferz colors in the 'projected advantage' is extremely important. If that advantage is not winnong, a reduction factor should be applied to the eval. I tried KF'F'FFKN, and Fairy-Max could win the Knight easily there.
I haven't tackled that one yet, but I've been thinking that I could drop the material advantage severely (perhaps by half) in positions with counting. That would dissuade the program from seeking them out when ahead (and cause it to look for them when behind, which is useless if the counting is not actually implemented).
Well, counting per se is not a problem. I think the count is generous enough to make KRK a certain win, so there would be no reason to discount that.
By the way, do you have an opinion on ASEAN chess? I've watched a few games and it looks like a broken version of Makruk to me. What speeds up the game in Makruk is that the pawns are advanced to begin with (basically a different solution to the problem with Shatranj that is solved by allowing pawns a double step) and that they promote very close to the front line of battle (rather than the back rank). This makes the game more dynamic. In ASEAN the pawns have to reach the back rank before they can promote, which makes promotion much more difficult and then when they finally get there your reward is a lousy ferz. It looks like a mistake to me.
I think you are right. Promoting to Ferz on the last rank makes it very difficult to keep that Ferz. I don't know why they invented thie; it doesn't seem to have any characteristics of Cambodian Chess anyway (of which it was supposed to be a synthesis). But there was a lot of stuff about it on the FIDE website, and some (Thai) people requested me to add it to WinBoard.