From 652c4c744d6e869c8735cadac5033ff2f7e1de55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduardo=20C=C3=A1ceres?= Date: Sat, 18 Jan 2025 23:44:05 +0100 Subject: [PATCH] Ensure that `HashfullPermillApprox` doesn't fail when tt length < 1k items --- src/Lynx/Model/TranspositionTable.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Lynx/Model/TranspositionTable.cs b/src/Lynx/Model/TranspositionTable.cs index d9628ada8..d78eb911c 100644 --- a/src/Lynx/Model/TranspositionTable.cs +++ b/src/Lynx/Model/TranspositionTable.cs @@ -126,11 +126,15 @@ public int HashfullPermill() => _tt.Length > 0 public readonly int HashfullPermillApprox() { int items = 0; - for (int i = 0; i < 1000; ++i) + + if (_tt.Length >= 1_000) { - if (_tt[i].Key != default) + for (int i = 0; i < 1_000; ++i) { - ++items; + if (_tt[i].Key != default) + { + ++items; + } } }