Defence vs. Attack

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

Moderators: hgm, Rebel, chrisw

Arpad Rusz
Posts: 273
Joined: Sat Apr 17, 2010 2:34 pm
Location: Budapest

Defence vs. Attack

Post by Arpad Rusz »

When a human plays chess it usually knows when it is attacking and when it is defending. Engines should also do the same!

For example, when the engine is on defence it is important for it to know that:

- Pawns restricted only to one flank give better chances to keep the draw. Some bonus is due for having shorter horizonthal and vertical pawn span.
- The fifty move counter should be taken into account when calculating the score for a position. A bigger fifty move counter should decrease the score.
- Undefended pieces get penalty but also a bigger number of defence relations between our pieces gets a bonus.
- King safety should have a bigger weight than when we are attacking.
- Pawns are better defenders near their original squares.
- In general, knights are better defenders than bishops. (E.g. two knights keep the draw against the queen, but BN/Q or BB/Q are lost endgames. On the other hand two knights cannot even checkmate a bare king. So when ahead, give a penalty to the knight pair but give it a bonus when you are in defence.)
- When defending, you should prefer closed positions.

Some of these can be applied all the time but maybe the engine sometimes should switch to some kind of a "Defence Mode". It is not easy to set the conditions because sometimes "a counterattack is the best defence". Anyway, I would suggest that in the endgame and at a -1.00 score the engine should definitively ponder switching to this special mode.
MikeGL
Posts: 1010
Joined: Thu Sep 01, 2011 2:49 pm

Re: Defence vs. Attack

Post by MikeGL »

Arpad Rusz wrote:When a human plays chess it usually knows when it is attacking and when it is defending. Engines should also do the same!

For example, when the engine is on defence it is important for it to know that:

- Pawns restricted only to one flank give better chances to keep the draw. Some bonus is due for having shorter horizonthal and vertical pawn span.
- The fifty move counter should be taken into account when calculating the score for a position. A bigger fifty move counter should decrease the score.
- Undefended pieces get penalty but also a bigger number of defence relations between our pieces gets a bonus.
- King safety should have a bigger weight than when we are attacking.
- Pawns are better defenders near their original squares.
- In general, knights are better defenders than bishops. (E.g. two knights keep the draw against the queen, but BN/Q or BB/Q are lost endgames. On the other hand two knights cannot even checkmate a bare king. So when ahead, give a penalty to the knight pair but give it a bonus when you are in defence.)
- When defending, you should prefer closed positions.

Some of these can be applied all the time but maybe the engine sometimes should switch to some kind of a "Defence Mode". It is not easy to set the conditions because sometimes "a counterattack is the best defence". Anyway, I would suggest that in the endgame and at a -1.00 score the engine should definitively ponder switching to this special mode.
I agree with almost all of your ideas posted above, but some of those I
guess can be set on engine config. Like the king safety issue and closed
position if defending can be set in contempt value in SF which is
also called respect config setting in McBrain. Most engines have this
setting which is effective if you know in advance whether the engine will
play against a human or against an engine.

I have peeked on the eval.c source of crafty and most fundamental ideas
in chess are implemented there I think. Like, when cramped and on very
low mobility position, it is better to liquidate so even if cramped you have
few pieces to maneuver on your limited space.

I have noticed in very difficult positions and puzzles where engines are
very weak, engines don't recognize that mobility of pieces always trumps
material which have limited mobility.


Take for instance the very old yet very tough Q sacrifice combination,
[d]4q1kr/p6p/1prQPppB/4n3/4P3/2P5/PP2B2P/R5K1 w - - 0 1

QxN of white wins automatically and would hamper the mobility of black
on this position. Not to mention the puzzles of Bláthy which showcases
mobility versus material and application of zugzwang techniques.


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

Re: Defence vs. Attack

Post by hgm »

Arpad Rusz wrote:- In general, knights are better defenders than bishops. (E.g. two knights keep the draw against the queen, but BN/Q or BB/Q are lost endgames.
KQKBN is a fortress draw, not?
BrendanJNorman
Posts: 2529
Joined: Mon Feb 08, 2016 12:43 am
Full name: Brendan J Norman

Re: Defence vs. Attack

Post by BrendanJNorman »

hgm wrote:
Arpad Rusz wrote:- In general, knights are better defenders than bishops. (E.g. two knights keep the draw against the queen, but BN/Q or BB/Q are lost endgames.
KQKBN is a fortress draw, not?
Even from visual memory, I'd say you're right.

The knight cooperates with the bishop (N on f3 and B on e4 for example) to control the color complex the bishop can't control and the enemy king cannot enter.
Arpad Rusz
Posts: 273
Joined: Sat Apr 17, 2010 2:34 pm
Location: Budapest

Re: Defence vs. Attack

Post by Arpad Rusz »

No, Q/BN is a general win. There is only one fortress but that can be reached from relatively few positions.

[D]7q/8/8/3k4/4N3/8/6B1/6K1 b - - 0 1

Similar is the case of Q/BB. There is only one fortress and everything must be almost set up.

[D]8/8/8/1k4q1/8/5BB1/6K1/8 b - - 0 1

(With the black king on c5 the fortress is already breakable.)

On the other hand, Q/NN is a general draw with lots of fortresses. One of the reasons could be that the two knights can defend each other.

But surprisingly, RB/NN is a general win! R+B is better than the Q against the knight pair!
User avatar
hgm
Posts: 27816
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Defence vs. Attack

Post by hgm »

You are probably right that the KQKBN fortress is too difficult to reach, and that most positions are wins. (But EGT statistics can be quite misleading: games don't sample them randomly. The defending side usually doesn't find himself after the conversion in a position where his pieces are up for grabs, while in most positions this would be the case, against a Queen with so much forking power.) I don't see such a spectacular difference between the stats of KQKNN and KQKBN: 43.14% vs 49.08% lost positions, though. Both are indicative of a general win. A genuine draw, like KQKRN has only 15.35% losses. KQKKK, which is a very dead draw, because even after loss of one of the non-royal Kings you can still build a fortress by merely preventing loss of the other has 10.84% lost positions.

Code: Select all

KQ_KBN

WON.wtm  225452011
K capture 92460382
other    132991629
  0.      66313822
 10.      16268470
 11.      17091017
 12.      14655324
 13.       8946465
 14.       4228621
 15.       2593769
 16.       2096304
 17.       1879422
 18.       1773702
 19.       1604827
 20.       1559460
 21.       1555910
 22.       1552533
 23.       1624128
 24.       1690355
 25.       1774602
 26.       1900568
 27.       1992411
 28.       2083225
 29.       2215011
 30.       2410084
 31.       2645471
 32.       2718968
 33.       2535096
 34.       2300367
 35.       2098550
 36.       2053125
 37.       2037515
 38.       1685879
 39.       1256548
 40.        823709
 41.        412461
 42.        115121
 43.         41461
 44.         27181
 45.          9954
 46.          4102
 47.          4168
 48.          1650
 49.           708
 50.            70
 51.            44
WON.btm  112268356
stalemate        2
W check   50153180
LEGAL    178582180
TOTAL    228735360

Code: Select all

KQ_KNN

WON.wtm  220533036
K capture 92460382
other    128072654
  0.      88765713
 10.      23884306
 11.      25428106
 12.      11114854
 13.       3591710
 14.       2225144
 15.       2040212
 16.       1995072
 17.       1882272
 18.       1805286
 19.       1767760
 20.       1787184
 21.       1751854
 22.       1749064
 23.       1681294
 24.       1566688
 25.       1382696
 26.       1261884
 27.       1165940
 28.       1030690
 29.        889960
 30.        782556
 31.        691232
 32.        615054
 33.        578874
 34.        552668
 35.        547090
 36.        499802
 37.        457988
 38.        435812
 39.        415072
 40.        394248
 41.        327686
 42.        293342
 43.        268780
 44.        229898
 45.        209894
 46.        194114
 47.        166466
 48.        144860
 49.        130104
 50.        124190
 51.        109114
 52.         90202
 53.         82080
 54.         68834
 55.         55836
 56.         55396
 57.         54744
 58.         38492
 59.         26728
 60.         18188
 61.         13332
 62.          7452
 63.          4300
 64.          2768
 65.          1216
 66.          1596
 67.           764
 68.           328
 69.           356
 70.           156
 71.            40
 72.            40
WON.btm   98693668
stalemate        0
W check   41275979
LEGAL    187459381
TOTAL    228735360
Arpad Rusz
Posts: 273
Joined: Sat Apr 17, 2010 2:34 pm
Location: Budapest

Re: Defence vs. Attack

Post by Arpad Rusz »

Almost all positions when the king defends the two knights which are on laterally adjacent squares are drawn.

[D]3qk3/8/8/8/3NN3/4K3/8/8 b - - 0 1

These positions are lost if we have two bishops or a bishop + knight against the queen.

[D]3qk3/8/8/8/3BB3/4K3/8/8 b - - 0 1

[D]3qk3/8/8/8/3BN3/4K3/8/8 b - - 0 1

Maybe a good indicator whether an endgame is a general draw or win could be the number of mutual zugzwangs. Both BB/Q and BN/Q has only one such position, while NN/Q has 229!

If the position doesn't have immediate queen capture, fork, or pin, then BB or BN has only a few percent chance to survive against a queen! (There is only one fortress in each of these endgames.)

NN has very good chances to survive against the Q, with the condition that the king and the two knights are near to each other. (There are countless fortresses available.)
Arpad Rusz
Posts: 273
Joined: Sat Apr 17, 2010 2:34 pm
Location: Budapest

Re: Defence vs. Attack

Post by Arpad Rusz »

Percentage of drawn positions (BTM, bK is not in check, bQ is not attacked):

BN/Q 0.02%
BB/Q 0.21%
NN/Q 4.14%
RN/Q 16.8%
RB/Q 21.56%
RR/Q 45.68%
BBauer
Posts: 658
Joined: Wed Mar 08, 2006 8:58 pm

Re: Defence vs. Attack

Post by BBauer »

Mike Libanan wrote:
Take for instance the very old yet very tough Q sacrifice combination,
[d]4q1kr/p6p/1prQPppB/4n3/4P3/2P5/PP2B2P/R5K1 w - - 0 1
QxN of white wins automatically and would hamper the mobility of black
on this position. Not to mention the puzzles of Bláthy which showcases
mobility versus material and application of zugzwang techniques.

Here is the game:
[Event "Molniya Sporting Society"]
[Site "Chelyabinsk RUS"]
[Date "1946.??.??"]
[EventDate "?"]
[Round "5"]
[Result "1-0"]
[White "Yuri S Gusev"]
[Black "E Auerbach"]
[ECO "B70"]
[WhiteElo "?"]
[BlackElo "?"]
[PlyCount "73"]

1.e4 c5 2.Nf3 d6 3.d4 cxd4 4.Nxd4 Nf6 5.Nc3 g6 6.Be2 Nc6 7.Nb3
Bg7 8.O-O Be6 9.f4 Rc8 10.f5 Bd7 11.g4 Ne5 12.g5 Ng8 13.Nd5 f6
14.Be3 b6 15.Nd4 Kf7 16.c3 Qe8 17.Ne6 Bxe6 18.fxe6+ Kf8
19.Nxf6 Nxf6 20.gxf6 Bxf6 21.Bh6+ Kg8 22.Rxf6 exf6 23.Qxd6 Rc6
24.Qxe5 fxe5 25.Rf1 Rc8 26.Bd1 Rc4 27.Bb3 b5 28.Bxc4 bxc4
29.b3 a5 30.bxc4 Qe7 31.Kg2 Qa3 32.Rf2 Qe7 33.Rf1 g5 34.Rf5 g4
35.c5 Qd8 36.c6 Qe7 37.c7 1-0

IMHO 29. ..a5 is a blunder wheras 29. ..bxc3 draws.
So the white win was not automatically.

Do you see a white win after 29. ..bxc3 ?
Kind regards
Bernhard
MikeGL
Posts: 1010
Joined: Thu Sep 01, 2011 2:49 pm

Re: Defence vs. Attack

Post by MikeGL »

BBauer wrote:Mike Libanan wrote:
Take for instance the very old yet very tough Q sacrifice combination,
[d]4q1kr/p6p/1prQPppB/4n3/4P3/2P5/PP2B2P/R5K1 w - - 0 1
QxN of white wins automatically and would hamper the mobility of black
on this position. Not to mention the puzzles of Bláthy which showcases
mobility versus material and application of zugzwang techniques.

Here is the game:
[Event "Molniya Sporting Society"]
[Site "Chelyabinsk RUS"]
[Date "1946.??.??"]
[EventDate "?"]
[Round "5"]
[Result "1-0"]
[White "Yuri S Gusev"]
[Black "E Auerbach"]
[ECO "B70"]
[WhiteElo "?"]
[BlackElo "?"]
[PlyCount "73"]

1.e4 c5 2.Nf3 d6 3.d4 cxd4 4.Nxd4 Nf6 5.Nc3 g6 6.Be2 Nc6 7.Nb3
Bg7 8.O-O Be6 9.f4 Rc8 10.f5 Bd7 11.g4 Ne5 12.g5 Ng8 13.Nd5 f6
14.Be3 b6 15.Nd4 Kf7 16.c3 Qe8 17.Ne6 Bxe6 18.fxe6+ Kf8
19.Nxf6 Nxf6 20.gxf6 Bxf6 21.Bh6+ Kg8 22.Rxf6 exf6 23.Qxd6 Rc6
24.Qxe5 fxe5 25.Rf1 Rc8 26.Bd1 Rc4 27.Bb3 b5 28.Bxc4 bxc4
29.b3 a5 30.bxc4 Qe7 31.Kg2 Qa3 32.Rf2 Qe7 33.Rf1 g5 34.Rf5 g4
35.c5 Qd8 36.c6 Qe7 37.c7 1-0

IMHO 29. ..a5 is a blunder wheras 29. ..bxc3 draws.
So the white win was not automatically.

Do you see a white win after 29. ..bxc3 ?
Kind regards
Bernhard
29...cxb3 instead of 29...a5
[d]4q1kr/p6p/4P1pB/4p3/2p1P3/1PP5/P6P/5RK1 b - - 0 29
After white played 29.b3

Thanks for the complete game. Yes it still looks like a win.
I tried to defend black as best as I could, but it seems the black Q would
run out of moves and black would be in complete zugzwang. Kindly
provide a possible better defense for black in case I missed some better
defence for black on my below attempt which I tried manually since
engines looks useless here because of zugzwangs at the end of the variation.

[pgn]
[Event "Computer chess game"]
[Site "Talkchess"]
[Date "2017.07.10"]
[Round "?"]
[White "?"]
[Black "?"]
[Result "*"]
[TimeControl "0+2"]
[SetUp "1"]
[FEN "4q1kr/p6p/4P1pB/4p3/2p1P3/1PP5/P6P/5RK1 b - - 0 29"]
[Termination "unterminated"]
[PlyCount "16"]
[WhiteType "human"]
[BlackType "human"]

29. ... cxb3 30. axb3 a6 31. b4 g5 (31. .. Qd8 32. Kg2 Qa8 33. Kg3 Qd8 34.
c4 {1-0}) 32. Kg2 Qd8 33. Rf2 Qa8 34. Kg3 Qd8 35. Rf3 Qe7 36. Rf5 Qd8 37.
c4 {1-0}
[/pgn]

King would advance to Kg3 > Kg4 possibly and Rook would lift to f3 or f6
too depending on blacks response. Looks like 1-0 on all variations.

But maybe I did miss something.