SharpChess.com Forum Index SharpChess.com
C# Chess Game
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Tactics

 
Post new topic   Reply to topic    SharpChess.com Forum Index -> Engine
View previous topic :: View next topic  
Author Message
Nimzo



Joined: 15 Mar 2005
Posts: 64

PostPosted: Mon May 09, 2005 5:25 pm    Post subject: Tactics Reply with quote

Part 7: Tactics

Part 7.1: Fork of pawn

Context: v 2.300 Debug, Level 8, Pondering ON, [x] Show Thinking

SharpChess2.exe menu "Edit" | "Paste FEN position"
or
SharpGenTest.exe
frmGenerator_Load [frmGenerator.cs]

Code:
sc.LevelDifficulty(8, 120, 16, 8);
strFEN = "r2qkb1r/ppp1pppp/2n1b3/8/B2PP3/5N1P/1P3PP1/R1BQK2R b KQkq - 0 6";

After the exchange of pawns, Whites have a strong center with the threat of the fork in d5.

Depending of the power of your computer, Blacks could reply Qb6? instead of Bd7.
If necessary reduce the level of difficulty.
________________

Part 7.1.1: Analysis

The Debug trace shows the Principal Variations v 2.210 at each iteration of depth.
<depth> <PV>: <alpha score>
1 Bc8: 1025, 1 Bf5: 1049, 1 Bd5: 1116, 1 Bb3: 1144

2 Bb3 Bxb3: -2937, 2 Bf5 exf5: -2095
2 Rc8 Bxc6 bxc6 Rxa7: 289
2 Bc4 Bb3 bxc6: 951

3 Bc4 Bxc6 bxc6 Be3: 999

4 Bc4 Ne5 Be6 Nxc6 bxc6 Bxc6: -239
4 Rb8 d5 b5 dxe6 bxa4 Qxa4 fxe6 Qc6: -12
4 f5 exf5 Bxf5 Bxc6 bxc6 O-O: 51
4 Qd6 O-O O-O-O Bb3 Qxc6 Rxa7 Qxe4: 505

5 Qd6 O-O O-O-O Bxc6 Qxc6 Be3 Qe4: 896 overestimation of the position
________________

With more time sc.LevelDifficulty(11, 120, 40, 32);
Computer could find the correct move Bd7.

6 Qd6 O-O Qd7 Bb5 Qd8 Be3 bxc6: 351
7 Qd6 d5 b5 dxe6 bxa4 exf7 Kxf7 Qxa4 Kg8: -503
7 Bd7 d5 Nb4 Bxd7 Qxd7 O-O c6 Be3 Nc6: 217
________________

Part 7.1.2: PositionalPoints [PiecePawn.cs]

The evaluation of the threat of the fork by the pawn will accelerate the research of the best move.
The cost is acceptable even when no forks are possible.

Code:
            intPoints += intAdvancementBonus + EvalForkPawn();
            return intPoints;
         }
      } // end PositionalPoints

________________

Part 7.1.3: EvalForkPawn [PiecePawn.cs]

If a pawn threatens a piece, add a light bonus.
If fork, add the value of the smallest piece.

Code:
      /// <summary>Eval the threat of fork by the pawn</summary>
      /// <returns><para>Min of the value of attacked pieces if fork</para>
      /// <para>30 if the pawn threatens a piece</para>
      /// <para>0 if not threat</para></returns>
      private int EvalForkPawn()
      {
         const int iTHREAT_PAWN = 30; int iBonus = 0; Square sqrLeft, sqrRight; Piece pieceLeft = null;
         if ((sqrLeft = Board.GetSquare(m_Base.Square.Ordinal + m_Base.Player.PawnAttackLeftOffset)) != null)
         {
            pieceLeft = sqrLeft.Piece;
            if (pieceLeft != null && pieceLeft.Player.Colour != m_Base.Player.Colour &&
               pieceLeft.IsCapturable && pieceLeft.Name != Piece.enmName.Pawn)
               iBonus = iTHREAT_PAWN; // see where CanBeDrivenAwayByPawn is called
         }
         if ((sqrRight = Board.GetSquare(m_Base.Square.Ordinal + m_Base.Player.PawnAttackRightOffset)) != null)
         {
            Piece pieceRight = sqrRight.Piece;
            if (pieceRight != null && pieceRight.Player.Colour != m_Base.Player.Colour &&
               pieceRight.IsCapturable && pieceRight.Name != Piece.enmName.Pawn)
               iBonus = (iBonus == iTHREAT_PAWN) ? Math.Min(pieceLeft.Value, pieceRight.Value) : iTHREAT_PAWN;
         }
         return iBonus;

      } // end EvalForkPawn

________________

Part 7.1.4: Analysis with EvalForkPawn

With: sc.LevelDifficulty(8, 120, 16, 8) Principal Variations v 2.210
1 Bc8: 1025, 1 Rc8: 1036, 1 Bd5: 1086, 1 Bb3: 1144 intPoints += intAdvancementBonus + EvalForkPawn();
1 Bc8: 1025, 1 Bf5: 1049, 1 Bd5: 1116, 1 Bb3: 1144 intPoints += intAdvancementBonus; // + EvalForkPawn();
About Bd5: alpha score 1086 = 1116 - 30

2 Bb3 Bxb3: -2937, 2 Bf5 exf5: -2095, 2 Bd5 exd5 Qxd5: -1316
2 Bc4 Bb3 bxc6: 951

3 Bc4 Bxc6 bxc6 Be3: 999
If Bc4?, d5 b5. dxc6 bxa4. Qxd8 Rxd8. Rxa4 Bb3. Rd4 Rxd4. Nxd4 Bc4. Bf4 Kd8. Kd2 +-

4 Bc4 Ne5 Bd5 exd5 Qxd5: -1358 Compare with 4 Bc4 Ne5 Be6 Nxc6 bxc6 Bxc6: -239
4 Bc8 d5 b5 Bxb5 bxa4 Qxa4: -305
4 Qd6 O-O Bc4 Bb3 Qxc6: 290 Compare with 4 Qd6 O-O O-O-O Bb3 Qxc6 Rxa7 Qxe4: 505
4 Bd7 d5 Nb4 O-O: 294

4 Bd7 d5 Nb4 O-O: 294
5 Bd7 d5 Nb8 Bxd7 Nxd7 O-O: 252 estimation more realistic than 5 Qd6 O-O O-O-O Bxc6 Qxc6 Be3 Qe4: 896

Nimzo
Back to top
View user's profile Send private message
peterhughes
Site Admin


Joined: 27 Feb 2005
Posts: 95

PostPosted: Wed Mar 15, 2006 3:18 pm    Post subject: Reply with quote

I've added your pawn threat code to v2.5.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    SharpChess.com Forum Index -> Engine All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group