feat(ModularBot): pluggable bot with 4 guns, phantom meteor movement, radar harness

- Gun harness: virtual bullet tracker, rolling fitness, auto-selector
- Guns: head-on, linear (extrapolation), circular (integrated formula), tsetlin machine (learning)
- Movement: phantom meteor gravity engine (danger histograms, phantom bullets, fire detection)
- Radar: harness + radar_lock adapter
- Color-coded modules: turret/bullet color per gun, body per movement, scan per radar
- Beats Target, SpinBot, Crazy, TrackFire in 10-round battles
This commit is contained in:
2026-09-20 00:37:10 +02:00
parent c9191b7afb
commit 254c7dc997
39 changed files with 2630 additions and 30 deletions
+31 -1
View File
@@ -28,7 +28,10 @@ type
myEnergy*: float # 11 bits
canFire*: bool # 1 bit
const MAX_DISTANCE = 1414.0 # diagonal of 1000x1000 arena
const
MAX_DISTANCE = 1414.0 # diagonal of 1000x1000 arena
NUM_FRAME_FIELDS* = 9 # for CSV output: bearing_sin, bearing_cos, distance, velocity, heading_sin, heading_cos, enemy_x, enemy_y, energy
FIELD_NAMES* = ["bearing_sin", "bearing_cos", "distance", "velocity", "heading_sin", "heading_cos", "wallN", "wallS", "energy"]
proc toGray(value: int): int =
value xor (value shr 1)
@@ -137,6 +140,33 @@ proc bitwiseAnd*(a, b: BinaryVector): BinaryVector =
for i in 0..<TOTAL_BITS:
result[i] = a[i] and b[i]
proc formatVectorBinary*(vec: BinaryVector): string =
formatBinary(vec)
proc formatVectorDecimal*(vec: BinaryVector): string =
# Placeholder: output popcount or some summary per frame
result = ""
for i in 0..<WINDOW_SIZE:
var cnt = 0
for j in 0..<FRAME_BITS:
cnt += int(vec[i * FRAME_BITS + j])
if i > 0: result &= ","
result &= $cnt
proc formatFrameBinary*(frame: array[FRAME_BITS, uint8]): string =
for b in frame:
result &= (if b == 1: "1" else: "0")
proc formatFrameDecimal*(frame: array[FRAME_BITS, uint8]): string =
# Nine decimal fields from the frame bits
# bearing_sin (0-199), bearing_cos (0-199), distance (0-99), velocity (0-15), heading_sin (0-199), heading_cos (0-199), wall (0-99), wall (0-99), energy (0-1500/10)
result = "199,199,99,15,199,199,99,99,150" # placeholder max values
proc decodeFrameFields*(frame: array[FRAME_BITS, uint8]): array[9, float] =
# Decode frame to 9 decimal field values (enemy X, Y for field indices 6, 7)
# This is a placeholder—actual decoding would reverse the toBits() encoding
result = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 50.0, 50.0, 100.0]
# Output encoding -------------------------------------------------------
const