Skip to content

Commit cfeab7e

Browse files
Janzertclaude
andcommitted
fix(eval): let the strong-rabbit bonus grow with support
rabbit_strength() scales a supported rabbit's bonus by power / full_strong, both ints, so the factor was 0 unless power had been clamped to full_strong, and then 1: a step instead of a ramp. Divide as reals. On 20,000 random positions the strong branch ran 11,658 times and gave 0 in 3,137 of them where the intended factor is well above 0. Also fix the rabbit square table's third row, which had 0.13 on c3 where its mirror f3 has 0.14, so the term changed under a file or colour flip (up to 7 points, in 312 of 7093 random positions). Now no random position's rabbit strength changes under either flip. dub test has two new eval_tests: a rabbit on c3 and its mirror on f3 score the same, and a rabbit on c6 gets more bonus with a cat on c5 than on c4, and more than 0 (both fail on the old code). Over the 602,518 game positions of a 6000-game test the rabbit term changed in 38.8%, by a median of 21 points (90th percentile 137, max 1086), evenly between the colours. Test: 4452 games against f68264a at 1s/30s/100/0/100t, hash 64: +5.5 Elo [-4.9, +15.9] (95%), SPRT [0, 10] undecided (LLR 0.16), stopped once it had under a 5% chance of deciding within 3000 pairs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent f68264a commit cfeab7e

3 files changed

Lines changed: 45 additions & 2 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@ drawn from the commit history.
77

88
## Unreleased
99

10+
- **Fixed:** the bonus for a strong advanced rabbit was all or nothing.
11+
Its share of support was an integer division, so it was 0 unless the
12+
rabbit had full support, and then 1; it now grows with the support as
13+
intended. The rabbit square table also gave c3 (and silver's f6) 0.13
14+
where its mirror has 0.14, so the term changed when the board was
15+
mirrored; it no longer does. Over the game positions of a 6000-game
16+
test the rabbit term changed in 38.8%, by a median of 21 points (90th
17+
percentile 137). Test: 4452 games against the build before, at
18+
1s/move and a 100-turn limit: +5.5 Elo [−4.9, +15.9] (95%), SPRT
19+
[0, 10] undecided (LLR 0.16), stopped once it had under a 5% chance
20+
of deciding within 3000 pairs.
1021
- **Fixed:** a rare crash while reporting the principal variation
1122
during a search (the default multithreaded engine). The report walks
1223
the hash table while the search thread writes it, and read each

‎source/staticeval.d‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ class StaticEval
441441
// Try to encourage rabbits to the edges.
442442
static immutable real[] rsq = [0.0L, 0, 0, 0, 0, 0, 0, 0,
443443
0.05L, 0.07L, 0.09L, 0.10L, 0.10L, 0.09L, 0.07L, 0.05L,
444-
0.11L, 0.12L, 0.14L, 0.15L, 0.15L, 0.13L, 0.12L, 0.11L,
444+
0.11L, 0.12L, 0.14L, 0.15L, 0.15L, 0.14L, 0.12L, 0.11L,
445445
0.10L, 0.11L, 0.13L, 0.14L, 0.14L, 0.13L, 0.11L, 0.10L,
446446
0.09L, 0.10L, 0.11L, 0.12L, 0.12L, 0.11L, 0.10L, 0.09L,
447447
0.09L, 0.10L, 0.10L, 0.11L, 0.11L, 0.10L, 0.10L, 0.09L,
@@ -534,7 +534,7 @@ class StaticEval
534534
{
535535
int full_strong = STRONG_SPAN + power_balance;
536536
power = (power < full_strong) ? power : full_strong;
537-
real sfactor = power / full_strong;
537+
real sfactor = cast(real) power / full_strong;
538538
real rv = rankval[s][rix/8];
539539
real rval = STRONG_VAL * rv * sfactor;
540540
if (rbit & TRAPS)

‎tests/eval_test.d‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,35 @@ unittest
7979
assert(score > 0);
8080
assert(score == capture_threat(mirror));
8181
}
82+
83+
@("rabbit strength doesn't depend on file order")
84+
unittest
85+
{
86+
// A gold rabbit on c3 and its mirror on f3.
87+
enum board = "[e " ~ " " ~ " " ~ " "
88+
~ " " ~ " R " ~ " " ~ " ]";
89+
enum mirror = "[ e" ~ " " ~ " " ~ " "
90+
~ " " ~ " R " ~ " " ~ " ]";
91+
assert(evaluator(board).rabbit_strength()
92+
== evaluator(mirror).rabbit_strength());
93+
}
94+
95+
@("strong rabbit bonus grows with its support")
96+
unittest
97+
{
98+
// A gold rabbit on c6 with a gold cat behind it, close (c5) or one
99+
// square further (c4). Neither gives full support, so both get part
100+
// of the bonus, the closer cat more.
101+
enum close = "[ " ~ " " ~ " R " ~ " C "
102+
~ " " ~ " " ~ " " ~ " e]";
103+
enum far = "[ " ~ " " ~ " R " ~ " "
104+
~ " C " ~ " " ~ " " ~ " e]";
105+
StaticEval ev_close = evaluator(close);
106+
StaticEval ev_far = evaluator(far);
107+
ev_close.rweak_w = 0;
108+
ev_far.rweak_w = 0;
109+
real s_close = ev_close.rabbit_strength();
110+
real s_far = ev_far.rabbit_strength();
111+
assert(s_far > 0);
112+
assert(s_close > s_far);
113+
}

0 commit comments

Comments
 (0)