Skip to content

Commit

Permalink
precompute mixednessRegions again
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasf committed Jul 9, 2023
1 parent ee5d46e commit 78f0704
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/main/scala/Divider.scala
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,16 @@ object Divider:

case _ => 0

private def mixedness(board: Board): Int = {
private val mixednessRegions: List[Bitboard] = {
val smallSquare = 0x0303L.bb
for
y <- 0 to 6
x <- 0 to 6
region = smallSquare << (x + 8 * y)
yield board.byColor.map(c => (c & region).count).reduce(score(y + 1))
}.sum
yield region
}.toList

private def mixedness(board: Board): Int =
mixednessRegions.foldLeft(0): (acc, region) =>
val y = region.first.get.rank.index + 1
acc + board.byColor.map(c => (c & region).count).reduce(score(y))

0 comments on commit 78f0704

Please sign in to comment.