Skip to content

Commit e05cef2

Browse files
committed
Gemini3
1 parent e7e7ea3 commit e05cef2

File tree

1 file changed

+41
-12
lines changed

1 file changed

+41
-12
lines changed

src/nnue/features/half_ka_v2_hm.h

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -170,25 +170,54 @@ class HalfKAv2_hm {
170170
}();
171171

172172
// LayerStack buckets
173-
static constexpr auto LayerStackBuckets = [] {
173+
static inline auto LayerStackBuckets = [] {
174174
std::array<std::array<std::array<std::array<uint8_t, 5>, 5>, 3>, 3> v{};
175175
for (uint8_t us_rook = 0; us_rook <= 2; ++us_rook)
176176
for (uint8_t opp_rook = 0; opp_rook <= 2; ++opp_rook)
177177
for (uint8_t us_knight_cannon = 0; us_knight_cannon <= 4; ++us_knight_cannon)
178178
for (uint8_t opp_knight_cannon = 0; opp_knight_cannon <= 4; ++opp_knight_cannon)
179179
v[us_rook][opp_rook][us_knight_cannon][opp_knight_cannon] = [&] {
180180
if (us_rook == opp_rook)
181-
return us_rook * 4
182-
+ int(us_knight_cannon + opp_knight_cannon >= 4) * 2
183-
+ int(us_knight_cannon == opp_knight_cannon);
184-
else if (us_rook == 2 && opp_rook == 1)
185-
return 12;
186-
else if (us_rook == 1 && opp_rook == 2)
187-
return 13;
188-
else if (us_rook > 0 && opp_rook == 0)
189-
return 14;
190-
else // us_rook == 0 && opp_rook > 0
191-
return 15;
181+
{
182+
// === 均势车力局面 (12个桶) ===
183+
// 我们用马炮数量差值的绝对值来衡量不平衡的程度
184+
int minor_imbalance =
185+
std::abs(static_cast<int>(us_knight_cannon)
186+
- static_cast<int>(opp_knight_cannon));
187+
188+
uint8_t sub_bucket;
189+
if (minor_imbalance == 0)
190+
{
191+
sub_bucket = 0; // 完全平衡
192+
}
193+
else if (minor_imbalance == 1)
194+
{
195+
sub_bucket = 1; // 轻度不平衡
196+
}
197+
else if (minor_imbalance == 2)
198+
{
199+
sub_bucket = 2; // 中度不平衡
200+
}
201+
else
202+
{ // >= 3
203+
sub_bucket = 3; // 高度不平衡
204+
}
205+
206+
return us_rook * 4 + sub_bucket;
207+
}
208+
else
209+
{
210+
// === 非均势车力局面 (4个桶) ===
211+
// 完全保留基线的逻辑
212+
if (us_rook == 2 && opp_rook == 1)
213+
return 12;
214+
else if (us_rook == 1 && opp_rook == 2)
215+
return 13;
216+
else if (us_rook > 0 && opp_rook == 0)
217+
return 14;
218+
else // us_rook == 0 && opp_rook > 0
219+
return 15;
220+
}
192221
}();
193222
return v;
194223
}();

0 commit comments

Comments
 (0)