From 7a86eeca0e2bbbac6a3bb98bab7d62f7857dcf81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduardo=20C=C3=A1ceres?= Date: Fri, 22 Nov 2024 02:24:16 +0100 Subject: [PATCH] Add KnightAttacksRooksBonus --- .../EvaluationParams.g.cs | 2 +- src/Lynx/Model/Position.cs | 8 +++----- src/Lynx/TunableEvalParameters.cs | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Lynx/Generated/Lynx.Generator/Lynx.Generator.GeneratedPackGenerator/EvaluationParams.g.cs b/src/Lynx/Generated/Lynx.Generator/Lynx.Generator.GeneratedPackGenerator/EvaluationParams.g.cs index 7f3b9660..9b0eef65 100644 --- a/src/Lynx/Generated/Lynx.Generator/Lynx.Generator.GeneratedPackGenerator/EvaluationParams.g.cs +++ b/src/Lynx/Generated/Lynx.Generator/Lynx.Generator.GeneratedPackGenerator/EvaluationParams.g.cs @@ -50,6 +50,6 @@ static partial class EvaluationParams /// /// /// - public const int QueenAttackedByKnightBonus = 131073; + public const int KnightAttacksRooksBonus = 131073; } diff --git a/src/Lynx/Model/Position.cs b/src/Lynx/Model/Position.cs index 77a9006f..ef8fbed3 100644 --- a/src/Lynx/Model/Position.cs +++ b/src/Lynx/Model/Position.cs @@ -733,11 +733,9 @@ private int KnightAdditionalEvaluation(int squareIndex, int pieceSide, int oppos var checks = (attacks & enemyKingCheckThreats).CountBits(); packedBonus += CheckBonus[(int)Piece.N] * checks; - // Attacks to enemy queens - if ((attacks & PieceBitBoards[(int)Piece.q - Utils.PieceOffset(pieceSide)]) != 0) - { - packedBonus += KnightAttacksQueenBonus; - } + // Attacks to enemy rooks + var rookAttacksCount = (attacks & PieceBitBoards[(int)Piece.r - Utils.PieceOffset(pieceSide)]).CountBits(); + packedBonus += KnightAttacksRooksBonus * rookAttacksCount; return packedBonus; } diff --git a/src/Lynx/TunableEvalParameters.cs b/src/Lynx/TunableEvalParameters.cs index e76fb59b..30f9ad8a 100644 --- a/src/Lynx/TunableEvalParameters.cs +++ b/src/Lynx/TunableEvalParameters.cs @@ -6044,7 +6044,7 @@ public static partial class EvaluationParams private static readonly int _PieceAttackedByPawnPenalty; [GeneratedPack(1, 2)] - private static readonly int _KnightAttacksQueenBonus; + private static readonly int _KnightAttacksRooksBonus; #pragma warning restore IDE0051, IDE0052, CS0169 // Remove unread private members