feat(BNNBot): switch to Gray code encoding for smooth Hamming distance

This commit is contained in:
2026-09-17 22:53:03 +02:00
parent 0f20e1a869
commit 27cc5720a3
2 changed files with 5 additions and 1 deletions
Binary file not shown.
+5 -1
View File
@@ -14,10 +14,14 @@ type
const MAX_DISTANCE = 1414.0 # diagonal of 1000x1000 arena
proc toGray(value: int): int =
value xor (value shr 1)
proc toBits(value: int, bits: int): seq[uint8] =
result = newSeq[uint8](bits)
let gray = toGray(value)
for i in 0..<bits:
result[bits - 1 - i] = uint8((value shr i) and 1)
result[bits - 1 - i] = uint8((gray shr i) and 1)
proc encode*(scan: ScanData): BinaryVector =
var offset = 0