Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

throw away lsb rather than msb of position hashes #594

Merged
merged 3 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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