feat(BNNBot): energy to 11 bits for 0.1 HP precision — 123 bits total

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-09-17 23:25:09 +02:00
parent 152fcba0cc
commit 89f63540bc
2 changed files with 11 additions and 11 deletions
Binary file not shown.
+11 -11
View File
@@ -1,7 +1,7 @@
import std/math import std/math
const const
TOTAL_BITS* = 117 TOTAL_BITS* = 123
type type
BinaryVector* = array[TOTAL_BITS, uint8] BinaryVector* = array[TOTAL_BITS, uint8]
@@ -87,17 +87,17 @@ proc encode*(scan: ScanData): BinaryVector =
for i in 0..<7: result[offset + i] = bits[i] for i in 0..<7: result[offset + i] = bits[i]
offset += 7 offset += 7
# 9. My energy (8 bits, 0-150) # 9. My energy (11 bits, 0-150 → 0-1500 with 0.1 HP precision)
let myE = int(clamp(scan.myEnergy / 150.0 * 149.0, 0.0, 149.0)) let myE = int(clamp(scan.myEnergy * 10.0, 0.0, 1500.0))
let myEBits = toBits(myE, 8) let myEBits = toBits(myE, 11)
for i in 0..<8: result[offset + i] = myEBits[i] for i in 0..<11: result[offset + i] = myEBits[i]
offset += 8 offset += 11
# 10. Enemy energy (8 bits, 0-150) # 10. Enemy energy (11 bits, 0-150 → 0-1500 with 0.1 HP precision)
let enE = int(clamp(scan.enemyEnergy / 150.0 * 149.0, 0.0, 149.0)) let enE = int(clamp(scan.enemyEnergy * 10.0, 0.0, 1500.0))
let enEBits = toBits(enE, 8) let enEBits = toBits(enE, 11)
for i in 0..<8: result[offset + i] = enEBits[i] for i in 0..<11: result[offset + i] = enEBits[i]
offset += 8 offset += 11
# 11. Can fire (1 bit) # 11. Can fire (1 bit)
result[offset] = if scan.canFire: 1'u8 else: 0'u8 result[offset] = if scan.canFire: 1'u8 else: 0'u8