feat(BNNBot): add similarity and overlap metrics to output

Output format: <tick> <44 bits> <hamming> <similarity> <overlap>
- Similarity: bits that are the same (TOTAL_BITS - hamming)
- Overlap: bits that are 1 in both vectors (popcount of bitwise AND)
- First tick: all metrics printed as 0

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-09-17 23:13:06 +02:00
parent 16c3e068fd
commit f82a74731d
3 changed files with 8 additions and 2 deletions
Binary file not shown.
+4 -2
View File
@@ -43,8 +43,10 @@ method onScannedBot*(bot: BNNBot, e: ScannedBotEvent) =
heading: bot.heading,
)
let vec = encode(scan)
let distance = if bot.hasPrev: hammingDistance(bot.prevVec, vec) else: 0
echo align($bot.tick, 4), " ", formatBinary(vec), " ", distance
let hamming = if bot.hasPrev: hammingDistance(bot.prevVec, vec) else: 0
let similarity = if bot.hasPrev: TOTAL_BITS - hamming else: 0
let overlap = if bot.hasPrev: popcount(bitwiseAnd(bot.prevVec, vec)) else: 0
echo align($bot.tick, 4), " ", formatBinary(vec), " ", hamming, " ", similarity, " ", overlap
bot.prevVec = vec
bot.hasPrev = true
+4
View File
@@ -71,3 +71,7 @@ proc popcount*(vec: BinaryVector): int =
proc hammingDistance*(a, b: BinaryVector): int =
for i in 0..<TOTAL_BITS:
result += int(a[i] xor b[i])
proc bitwiseAnd*(a, b: BinaryVector): BinaryVector =
for i in 0..<TOTAL_BITS:
result[i] = a[i] and b[i]