Skip to content

Commit

Permalink
🧹 Move eval params to its own class and make all of them `static read…
Browse files Browse the repository at this point in the history
…only` (#911)
  • Loading branch information
eduherminio authored Aug 12, 2024
1 parent 8e3abd5 commit 3e87e0a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/Lynx/Model/Position.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Text;

using static Lynx.EvaluationConstants;
using static Lynx.EvaluationParams;

namespace Lynx.Model;

Expand Down
15 changes: 8 additions & 7 deletions src/Lynx/TunableEvalParameters.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// 2024-8-9 2:23:22 51

using System.Runtime.CompilerServices;

namespace Lynx;

#pragma warning disable IDE0055, IDE1006 // Discard formatting and naming styles
Expand Down Expand Up @@ -3007,7 +3005,10 @@ public static partial class EvaluationConstants
0, 0, 0, 0, 0, 0, 0, 0,
],
];
}

public static class EvaluationParams
{
public static readonly TaperedEvaluationTerm IsolatedPawnPenalty = new(-19, -15);

public static readonly TaperedEvaluationTerm OpenFileRookBonus = new(42, 7);
Expand All @@ -3028,7 +3029,7 @@ public static partial class EvaluationConstants

public static readonly TaperedEvaluationTerm PieceAttackedByPawnPenalty = new(-43, -27);

public static TaperedEvaluationTermByRank PassedPawnBonus { [MethodImpl(MethodImplOptions.AggressiveInlining)] get; } = new(
public static readonly TaperedEvaluationTermByRank PassedPawnBonus = new(
new(0, 0),
new(7, 15),
new(-0, 21),
Expand All @@ -3038,7 +3039,7 @@ public static partial class EvaluationConstants
new(228, 273),
new(0, 0));

public static TaperedEvaluationTermByCount27 VirtualKingMobilityBonus { [MethodImpl(MethodImplOptions.AggressiveInlining)] get; } = new(
public static readonly TaperedEvaluationTermByCount27 VirtualKingMobilityBonus = new(
new(0, 0),
new(0, 0),
new(0, 0),
Expand Down Expand Up @@ -3068,7 +3069,7 @@ public static partial class EvaluationConstants
new(-16, -75),
new(-2, -87));

public static TaperedEvaluationTermByCount8 KnightMobilityBonus { [MethodImpl(MethodImplOptions.AggressiveInlining)] get; } = new(
public static readonly TaperedEvaluationTermByCount8 KnightMobilityBonus = new(
new(0, 0),
new(20, -7),
new(27, 4),
Expand All @@ -3079,7 +3080,7 @@ public static partial class EvaluationConstants
new(29, 11),
new(30, 5));

public static TaperedEvaluationTermByCount14 BishopMobilityBonus { [MethodImpl(MethodImplOptions.AggressiveInlining)] get; } = new(
public static readonly TaperedEvaluationTermByCount14 BishopMobilityBonus= new(
new(-277, -301),
new(0, 0),
new(10, -20),
Expand All @@ -3096,7 +3097,7 @@ public static partial class EvaluationConstants
new(86, 110),
new(0, 0));

public static TaperedEvaluationTermByCount14 RookMobilityBonus { [MethodImpl(MethodImplOptions.AggressiveInlining)] get; } = new(
public static readonly TaperedEvaluationTermByCount14 RookMobilityBonus = new(
new(0, 0),
new(9, 24),
new(14, 25),
Expand Down
2 changes: 2 additions & 0 deletions tests/Lynx.Test/EvaluationConstantsTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using Lynx.Model;
using NUnit.Framework;

using static Lynx.EvaluationConstants;
using static Lynx.EvaluationParams;

namespace Lynx.Test;
public class EvaluationConstantsTest
Expand Down
1 change: 1 addition & 0 deletions tests/Lynx.Test/Model/PositionTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Lynx.Model;
using NUnit.Framework;
using static Lynx.EvaluationConstants;
using static Lynx.EvaluationParams;

namespace Lynx.Test.Model;

Expand Down

0 comments on commit 3e87e0a

Please sign in to comment.