Skip to content

Commit

Permalink
Reordered SearchStackEntry layout (liamt19#58)
Browse files Browse the repository at this point in the history
bench: 4697595
  • Loading branch information
liamt19 authored Jul 26, 2024
1 parent 19a0559 commit 04a3638
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
24 changes: 12 additions & 12 deletions Logic/Search/SearchStackEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ namespace Lizard.Logic.Search
/// <summary>
/// Used during a search to keep track of information from earlier plies/depths
/// </summary>
[StructLayout(LayoutKind.Explicit, Size = 40)]
[StructLayout(LayoutKind.Explicit, Size = 32)]
public unsafe struct SearchStackEntry
{
public static SearchStackEntry NullEntry = new SearchStackEntry();

[FieldOffset( 0)] public Move CurrentMove;
[FieldOffset( 4)] public Move Skip;
[FieldOffset( 0)] public Move* PV;
[FieldOffset( 8)] public PieceToHistory* ContinuationHistory;
[FieldOffset(16)] public int DoubleExtensions;
[FieldOffset(20)] public short Ply;
[FieldOffset(22)] public short StaticEval;
[FieldOffset(24)] public bool InCheck;
[FieldOffset(25)] public bool TTPV;
[FieldOffset(26)] public bool TTHit;
[FieldOffset(27)] private fixed byte _pad0[1];
[FieldOffset(28)] public Move KillerMove;
[FieldOffset(32)] public Move* PV;
[FieldOffset(16)] public short DoubleExtensions;
[FieldOffset(18)] public short Ply;
[FieldOffset(20)] public short StaticEval;
[FieldOffset(22)] public Move KillerMove;
[FieldOffset(24)] public Move CurrentMove;
[FieldOffset(26)] public Move Skip;
[FieldOffset(28)] public bool InCheck;
[FieldOffset(29)] public bool TTPV;
[FieldOffset(30)] public bool TTHit;
[FieldOffset(31)] private fixed byte _pad0[1];


public SearchStackEntry()
Expand Down
2 changes: 1 addition & 1 deletion Logic/Search/Searches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ public static int Negamax<NodeType>(Position pos, SearchStackEntry* ss, int alph

int histIdx = PieceToHistory.GetIndex(us, ourPiece, moveTo);

ss->DoubleExtensions = (ss - 1)->DoubleExtensions + (extend == 2 ? 1 : 0);
ss->DoubleExtensions = (short)((ss - 1)->DoubleExtensions + (extend >= 2).AsInt());
ss->CurrentMove = m;
ss->ContinuationHistory = history.Continuations[ss->InCheck.AsInt()][isCapture.AsInt()][histIdx];
thisThread.Nodes++;
Expand Down

0 comments on commit 04a3638

Please sign in to comment.