feat: implement HalfKAv2_hm feature extraction (352 features)

- Use oriented squares for piece encoding
- 24 pieces + 1 king bucket = 25 active features on starting position
- King bucket features prefer white king perspective
- All tests passing (11 tests)
This commit is contained in:
2026-04-14 18:35:10 -05:00
parent 334bc313b0
commit 319c0a1704
2 changed files with 69 additions and 10 deletions

View File

@@ -16,14 +16,13 @@ class TestFeatureExtraction:
features = fen_to_features(fen)
assert len(features) == TOTAL_FEATURES
def test_full_threats_features(self):
"""Test FullThreats produces correct number of features"""
def test_half_ka_v2_hm_features(self):
"""Test HalfKAv2_hm produces correct number of features"""
fen = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"
features = fen_to_features(fen)
active = sum(features)
# FullThreats: for each attacking piece, each attacked piece
# Should be many more than 32 (all attack relationships)
assert active >= 32 # At least one attack per piece
# HalfKAv2_hm: 24 pieces + 1 king bucket = 25 features
assert active == 25
def test_feature_range(self):
"""Test all features are in valid range"""
@@ -36,7 +35,7 @@ class TestFeatureExtraction:
fen = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR b KQkq - 0 1"
features = fen_to_features(fen)
active = sum(features)
assert active >= 32 # FullThreats from black's perspective
assert active > 20 # Multiple pieces from black's perspective
def test_mixed_colors(self):
"""Test feature extraction with both colors on board"""