From bd9bc13120927bf46a5ce1165f2ae8e19f5a4e7a Mon Sep 17 00:00:00 2001 From: Jonathan Gamble <101470903+schlawg@users.noreply.github.com> Date: Tue, 5 Nov 2024 16:59:45 -0600 Subject: [PATCH 1/3] throw away lsb rather than msb of hashes for compatibility with lichess-org/compression fix #16317 --- core/src/main/scala/Hash.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/scala/Hash.scala b/core/src/main/scala/Hash.scala index db7a5cda2..a1c8a320e 100644 --- a/core/src/main/scala/Hash.scala +++ b/core/src/main/scala/Hash.scala @@ -30,7 +30,7 @@ opaque type Hash = Int object Hash: val size = 3 def apply(value: Int): Hash = value & 0x00ff_ffff - def apply(situation: Situation): Hash = hashSituation(situation) & 0x00ff_ffff + def apply(situation: Situation): Hash = hashSituation(situation) >>> 8 private def hashSituation(situation: Situation): Int = import situation.board From dd8033f4d84b21f588e602e3ce3121c99583ebaf Mon Sep 17 00:00:00 2001 From: Jonathan Gamble Date: Tue, 5 Nov 2024 19:44:18 -0600 Subject: [PATCH 2/3] apply(Int) should also discard lsb --- core/src/main/scala/Hash.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/scala/Hash.scala b/core/src/main/scala/Hash.scala index a1c8a320e..f2db9a2e2 100644 --- a/core/src/main/scala/Hash.scala +++ b/core/src/main/scala/Hash.scala @@ -29,7 +29,7 @@ object PositionHash: opaque type Hash = Int object Hash: val size = 3 - def apply(value: Int): Hash = value & 0x00ff_ffff + def apply(value: Int): Hash = value >>> 8 def apply(situation: Situation): Hash = hashSituation(situation) >>> 8 private def hashSituation(situation: Situation): Int = From 64c945e06622d1843b0f8deb1029df1d4e5c32ee Mon Sep 17 00:00:00 2001 From: Jonathan Gamble Date: Tue, 5 Nov 2024 19:59:26 -0600 Subject: [PATCH 3/3] fix history test --- test-kit/src/test/scala/HistoryTest.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-kit/src/test/scala/HistoryTest.scala b/test-kit/src/test/scala/HistoryTest.scala index 2713c2242..d3092244e 100644 --- a/test-kit/src/test/scala/HistoryTest.scala +++ b/test-kit/src/test/scala/HistoryTest.scala @@ -2,7 +2,7 @@ package chess class ThreefoldRepetitionTest extends ChessTest: - def toHash(a: Int) = PositionHash(Hash(a)) + def toHash(a: Int) = PositionHash(Hash(a << 8)) def makeHistory(positions: List[Int]) = (positions .map(toHash))