Skip to content

Commit

Permalink
Merge pull request #594 from lichess-org/discard-least-significant-ha…
Browse files Browse the repository at this point in the history
…sh-byte

throw away lsb rather than msb of position hashes
  • Loading branch information
niklasf authored Nov 6, 2024
2 parents 6bf25de + 64c945e commit c3774a4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions core/src/main/scala/Hash.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ object PositionHash:
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(value: Int): Hash = value >>> 8
def apply(situation: Situation): Hash = hashSituation(situation) >>> 8

private def hashSituation(situation: Situation): Int =
import situation.board
Expand Down
2 changes: 1 addition & 1 deletion test-kit/src/test/scala/HistoryTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit c3774a4

Please sign in to comment.