Page 1 of 1
Anti Coward Mode
Posted: Sun Dec 22, 2013 7:04 am
by lucasart
I would like to implement an Anti Human Coward mode in my engine. What I have currently is a "contempt" feature which is simply the draw score (draws by chess rules detected by search are scored based on contempt). That's fine for teaching the engine to refuse these undeserved 3-repetition draws that human manage to get from time to time. But it does nothing as far as preventing anti computer play. The essence of anti comp play is to create blocked positions, where there is nothing to calculate, and it's all about long term strategy. In such positions the engine is crippled and cannot use effectively his tactical superiority over humans. That's the only way humans manage to win, even today, some games against the strongest comp.
I'm thinking of adding an anti human mode with asymmetric eval terms such as:
* penalize blocked pawn structures (for the comp side) and reward them equally for the opponent side
* devise an asymetric penalty based directly on the game phase: the more material on the board the better for the comp and the worse for the opponent. That should prevent anti comp strategies based on exchanging all pieces as fast as possible.
I've been toying with it, and so far nothing very interesting. All these features seem to hurt a lot in self-play. While I do expect this to be an elo gambit, it should not lose too much elo either.
What do other engines do ?
Any idea and/or experimental results you can share, are welcome!
PS: I would like to prove to Lyudmil Tsvetkov that, even a "weak" engine like DiscoCheck, can demolish him in every single game if I can teach it to not fall for these cowardly human plans to draw by exchanging all pieces or by blocking all the pawns.
Re: Anti Coward Mode
Posted: Sun Dec 22, 2013 8:43 am
by Rebel
A couple tricks that helped me while playing GM's in the late 90's and early 2000's.
1. Add a small bonus (root positions only) leaving pawns hanging, double bonus for pieces hanging, double the bonus again if you have 2 pieces hanging. It will complicate the position. There hardly is any loss in playing strength.
2. More aggressive King Safety. Tricky, but it guarantees long thoughts.
3. Permanent Brain, play from it instantly (within safety bounds of course), it drives them crazy especially when they themselves have little time on the clock left. I have witnessed the annoying looks when a serie of 4-5 moves were executed on the board instantly. It worked.
Re: Anti Coward Mode
Posted: Sun Dec 22, 2013 10:35 am
by lucasart
Interesting. Although not really what I'm looking for. 1/ and 2/ are only useful if the human takes the bate. But the problem is the opponent is a coward who will try by all means to create blocked and symmetric pawn structures, and exchange pieces as fast as possible. This is the problem. 3/ is psychological: I already do it, but not for that reason (simplicity of implementation): on ponder hit I use the normal time allocation, if consumed, I play (can be instantly or very quick depending on how long opponent took for last move).
The more I look at games like that, the more I realize the solution must be found in pawn structures. If only I could teach the engine to avoid at all cost blocked pawn chains, the rest is not a problem. If the engine manages to keep the position open and asymmetric and double edged, there is no need to add any tricks: the human will get destroyed in a few moves without any effort. The key is to prevent this cowardly play.
Reversly, if I could make my engine play anti comp strategy itself, so I can switch it on and gets lots of draws against SF and Houdini, that would be cool too
Although it would not be the default mode, of course. By default it should be enterprising and aggressive, and assume the opponent is also willing to play, not to block the game.
Anyway, I'll do some experiments and post here if I have anything interesting. The real difficulty is to test such a mode. By definition I cannot test an "improvement" in the field of anti human play, unless GMs are willing to play thousands of games against DiscoCheck. What I have in mind is to make the option symmetric: with a negative value it would play coward strategy, and I would see if DC manages to score better against much stronger engines (by drawing more games blocking pawn structures).
Re: Anti Coward Mode
Posted: Sun Dec 22, 2013 1:28 pm
by Chris Whittington
lucasart wrote:Interesting. Although not really what I'm looking for. 1/ and 2/ are only useful if the human takes the bate. But the problem is the opponent is a coward who will try by all means to create blocked and symmetric pawn structures, and exchange pieces as fast as possible. This is the problem. 3/ is psychological: I already do it, but not for that reason (simplicity of implementation): on ponder hit I use the normal time allocation, if consumed, I play (can be instantly or very quick depending on how long opponent took for last move).
The more I look at games like that, the more I realize the solution must be found in pawn structures. If only I could teach the engine to avoid at all cost blocked pawn chains, the rest is not a problem. If the engine manages to keep the position open and asymmetric and double edged, there is no need to add any tricks: the human will get destroyed in a few moves without any effort. The key is to prevent this cowardly play.
Reversly, if I could make my engine play anti comp strategy itself, so I can switch it on and gets lots of draws against SF and Houdini, that would be cool too
Although it would not be the default mode, of course. By default it should be enterprising and aggressive, and assume the opponent is also willing to play, not to block the game.
Anyway, I'll do some experiments and post here if I have anything interesting. The real difficulty is to test such a mode. By definition I cannot test an "improvement" in the field of anti human play, unless GMs are willing to play thousands of games against DiscoCheck. What I have in mind is to make the option symmetric: with a negative value it would play coward strategy, and I would see if DC manages to score better against much stronger engines (by drawing more games blocking pawn structures).
you should identify the pawn structures and then use the appropriate evaluation (yes, i know this is obvious). have you tried gettign a mass of games, or leaving your engine running for zillions of games, and identifying the number of different pawn structures that actually arise - it's a lot less than max possible, which is also less than max by random placement. which end up winning and which don't? what difference do piece combinations make? should you like knights over bishops, blah blah, I'm sure you can intuit the possibilities. The possibles might be hashable into some sort of magic table, you never know, or the frequent possibles, infrequent could be calculated somehow, or ANN-ed if they don't happen often. I would guess that some of this might be being done (secretly) by one or two of the very strong programs.
Re: Anti Coward Mode
Posted: Mon Dec 23, 2013 5:16 am
by lucasart
Chris Whittington wrote:
you should identify the pawn structures and then use the appropriate evaluation (yes, i know this is obvious). have you tried gettign a mass of games, or leaving your engine running for zillions of games, and identifying the number of different pawn structures that actually arise - it's a lot less than max possible, which is also less than max by random placement. which end up winning and which don't? what difference do piece combinations make? should you like knights over bishops, blah blah, I'm sure you can intuit the possibilities. The possibles might be hashable into some sort of magic table, you never know, or the frequent possibles, infrequent could be calculated somehow, or ANN-ed if they don't happen often. I would guess that some of this might be being done (secretly) by one or two of the very strong programs.
What you are describing here is basically a pawn hash table. And you are suggesting that I hardcode it inside my program ? That's beyond ugly, and cheating, really. I will never do that in my program. Of course, I have a pawn hash table, but its content is filled dynamically, not statically loaded.
Anyway, this has nothing to do with the problem at hand. It's merely a speed optimization. In an anti human mode, I don't care about speed. Even if my NPS is halved, so long as I prevent cowardly strategies from the opponent to block the pawn structures, it's a net gain against humans. Whether the comp is 100x or 200x stronger than humans at pure tactics is not important, that's not where the games (ones that human draw or win) are decided.
Re: Anti Coward Mode
Posted: Mon Dec 23, 2013 6:31 pm
by Rebel
lucasart wrote:PS: I would like to prove to Lyudmil Tsvetkov that, even a "weak" engine like DiscoCheck, can demolish him in every single game if I can teach it to not fall for these cowardly human plans to draw by exchanging all pieces or by blocking all the pawns.
Aha, when it's about this guy then Chris' suggestion is not so bad. With an util create a special pawn hash table that creates the most important pawn chains, then asymmetrically penalize them. Another suggestion is to asymmetrically bonus
the number of (semi) open files.
Re: Anti Coward Mode
Posted: Mon Dec 23, 2013 7:00 pm
by hyatt
There are several things I do, although what I do is far, far from optimal.
1. Pawn levers. Sometimes called "potential pawn breaks". If you have none available, you have to live with the existing pawn structure. If you don't have any entry to the opponent side, you draw unless your opponent does something.
2. There are other special cases of the above. "pawn rams" are well known but are really the absence of levers, so that covers both.
3. There are versions of Crafty that go farther, but there is cost. For example, detecting the a2-b3-c4-d5-e4-f3-g2 type of blocked position (opponent pawns ram every one of those, a classic anti-computer position). But how often do you see that? And rather than going for outright recognition of something you can't break through, the pawn lever comes to your aid again. Use an exponential score. No levers... really bad penalty. one lever, only 1/2 the penalty, etc.
The thing I don't do is to make this asymmetric. For example, if I am down in material, blocking the pawns can "sometimes" be good (the usual rule is if behind in material, trade pawns but not pieces). That means that the "lever bonus/penalty" has to take into account whether that side is better or worse overall. For example, in the above pawn chain, adding in h pawns to "seal things up" if the white pawn on d5 is passed (and also protected) white might be happy. Too happy. Because it is hard to advance that passed pawn if you can't get to the black side of the board. If you are on the white side, you want one or more levers to give you a way to break in. If you are on the black side, you'd probably be happy to lock the pawns and force the draw. I've not gotten around to that, as of yet, but it is on my list. The real problem is that locked pawns can be good OR bad, depending on the underlying position.
I've not had problems with locked pawns in many years playing on ICC. Yes you will occasionally get into one, but if you do this carefully, most of the time you stop it before it gets started, needing only to be just a bit careful with pawn structure in specific openings where locking things up is more common.
Re: Anti Coward Mode
Posted: Tue Dec 24, 2013 5:35 am
by lucasart
Rebel wrote:lucasart wrote:Another suggestion is to asymmetrically bonus the number of (semi) open files.
Interesting, I'll give it a try. I'm actually wondering whether half open files are not better (to create asymmetry) than open files. The typical human coward would use open files to exchange both rooks ASAP.
Re: Anti Coward Mode
Posted: Tue Dec 24, 2013 5:38 am
by lucasart
hyatt wrote:There are several things I do, although what I do is far, far from optimal.
1. Pawn levers. Sometimes called "potential pawn breaks". If you have none available, you have to live with the existing pawn structure. If you don't have any entry to the opponent side, you draw unless your opponent does something.
2. There are other special cases of the above. "pawn rams" are well known but are really the absence of levers, so that covers both.
3. There are versions of Crafty that go farther, but there is cost. For example, detecting the a2-b3-c4-d5-e4-f3-g2 type of blocked position (opponent pawns ram every one of those, a classic anti-computer position). But how often do you see that? And rather than going for outright recognition of something you can't break through, the pawn lever comes to your aid again. Use an exponential score. No levers... really bad penalty. one lever, only 1/2 the penalty, etc.
The thing I don't do is to make this asymmetric. For example, if I am down in material, blocking the pawns can "sometimes" be good (the usual rule is if behind in material, trade pawns but not pieces). That means that the "lever bonus/penalty" has to take into account whether that side is better or worse overall. For example, in the above pawn chain, adding in h pawns to "seal things up" if the white pawn on d5 is passed (and also protected) white might be happy. Too happy. Because it is hard to advance that passed pawn if you can't get to the black side of the board. If you are on the white side, you want one or more levers to give you a way to break in. If you are on the black side, you'd probably be happy to lock the pawns and force the draw. I've not gotten around to that, as of yet, but it is on my list. The real problem is that locked pawns can be good OR bad, depending on the underlying position.
I've not had problems with locked pawns in many years playing on ICC. Yes you will occasionally get into one, but if you do this carefully, most of the time you stop it before it gets started, needing only to be just a bit careful with pawn structure in specific openings where locking things up is more common.
Very interesting. I'll have to educate myself on what pawn levers and pawn rams are exactly, and experiment with that. But yes, that's the idea. Actively prevent sterile pawn structures.
Re: Anti Coward Mode
Posted: Tue Dec 24, 2013 8:50 pm
by hyatt
lucasart wrote:Rebel wrote:lucasart wrote:Another suggestion is to asymmetrically bonus the number of (semi) open files.
Interesting, I'll give it a try. I'm actually wondering whether half open files are not better (to create asymmetry) than open files. The typical human coward would use open files to exchange both rooks ASAP.
From a pure chess player point of view, I don't like the idea. The general idea in pawn structure is to have as FEW pawn islands as possible, not as many as you can create. half-open files simply mark the boundary between two pawn islands. Which would you generally prefer? (a) three pawns on one side, two on the other; (b) 3 tripled isolated pawns and 1 pair? Blindly counting files with no friendly pawns doesn't seem productive to a chess player.