feat: Suppress SonarQube warnings in PolyglotBook and ZobristHash by adding NOSONAR comments
Build & Test (NowChessSystems) TeamCity build finished
Build & Test (NowChessSystems) TeamCity build finished
This commit is contained in:
@@ -120,12 +120,11 @@ final class PolyglotBook(path: String):
|
|||||||
Move(from, to, MoveType.Normal())
|
Move(from, to, MoveType.Normal())
|
||||||
|
|
||||||
/** Select a weighted random move from the list of book entries. */
|
/** Select a weighted random move from the list of book entries. */
|
||||||
@scala.annotation.nowarn("msg=scala:S2245")
|
|
||||||
private def weightedRandom(entries: Vector[BookEntry]): BookEntry =
|
private def weightedRandom(entries: Vector[BookEntry]): BookEntry =
|
||||||
if entries.length == 1 then entries.head
|
if entries.length == 1 then entries.head
|
||||||
else
|
else
|
||||||
val totalWeight = entries.map(_.weight).sum
|
val totalWeight = entries.map(_.weight).sum
|
||||||
val pick = Random.nextInt(totalWeight.max(1))
|
val pick = Random.nextInt(totalWeight.max(1)) // NOSONAR
|
||||||
|
|
||||||
@scala.annotation.tailrec
|
@scala.annotation.tailrec
|
||||||
def select(remaining: Int, idx: Int): BookEntry =
|
def select(remaining: Int, idx: Int): BookEntry =
|
||||||
|
|||||||
@@ -12,8 +12,7 @@ object ZobristHash:
|
|||||||
private val pieceRands: Array[Long] = Array.ofDim(768)
|
private val pieceRands: Array[Long] = Array.ofDim(768)
|
||||||
|
|
||||||
// Side-to-move: XOR when Black to move
|
// Side-to-move: XOR when Black to move
|
||||||
@scala.annotation.nowarn("msg=scala:S2245")
|
private val sideToMoveRand: Long = Random(0x1badb002L).nextLong() // NOSONAR
|
||||||
private val sideToMoveRand: Long = Random(0x1badb002L).nextLong()
|
|
||||||
|
|
||||||
// 4 entries: White kingside, White queenside, Black kingside, Black queenside
|
// 4 entries: White kingside, White queenside, Black kingside, Black queenside
|
||||||
private val castlingRands: Array[Long] = Array.ofDim(4)
|
private val castlingRands: Array[Long] = Array.ofDim(4)
|
||||||
@@ -23,8 +22,7 @@ object ZobristHash:
|
|||||||
|
|
||||||
// Initialize all random values using a seeded RNG for reproducibility
|
// Initialize all random values using a seeded RNG for reproducibility
|
||||||
locally:
|
locally:
|
||||||
@scala.annotation.nowarn("msg=scala:S2245")
|
val rng = Random(0x1badb002L) // NOSONAR
|
||||||
val rng = Random(0x1badb002L)
|
|
||||||
for i <- 0 until 768 do pieceRands(i) = rng.nextLong()
|
for i <- 0 until 768 do pieceRands(i) = rng.nextLong()
|
||||||
for i <- 0 until 4 do castlingRands(i) = rng.nextLong()
|
for i <- 0 until 4 do castlingRands(i) = rng.nextLong()
|
||||||
for i <- 0 until 8 do enPassantRands(i) = rng.nextLong()
|
for i <- 0 until 8 do enPassantRands(i) = rng.nextLong()
|
||||||
|
|||||||
Reference in New Issue
Block a user