The code in question is this:
extern voidshow_keith(TanBoard an, char *sz){
int pn[2];
float fL;
KeithCount((ConstTanBoard) an, pn);
fL = (float) pn[1] * 8.0f / 7.0f;
sprintf(sz, _("Keith Count Leader : %d\n"), pn[1]);
sprintf(strchr(sz, 0), _("Keith Count Leader(+1/7) L: %.1f\n"), fL);
sprintf(strchr(sz, 0), _("Keith Count Trailer T: %d\n\n"), pn[0]);
if ((float) pn[0] >= (fL - 2.0f))
sprintf(strchr(sz, 0), _("Double, Drop (since L <= T+2)"));
else if ((float) pn[0] >= (fL - 3.0f))
sprintf(strchr(sz, 0), _("Redouble, Take (since L <= T+3)"));
else if ((float) pn[0] >= (fL - 4.0f))
sprintf(strchr(sz, 0), _("Double, Take (since L <= T + 4)"));
else
sprintf(strchr(sz, 0), _("No Double, Take (since L > T + 4)"));}
To me it looks like this code adds the 1/7 as float and does not round
down. Will rounding down to the nearest integer (floor) solve the
issue?
Totally untested, I would suggest this:
extern voidshow_keith(TanBoard an, char *sz){
int pn[2];
KeithCount((ConstTanBoard) an, pn);
int L = pn[1] * 8 / 7;
sprintf(sz, _("Keith Count Leader : %d\n"), pn[1]);
sprintf(strchr(sz, 0), _("Keith Count Leader(+1/7) L: %d\n"), L);
sprintf(strchr(sz, 0), _("Keith Count Trailer T: %d\n\n"), pn[0]);
if (pn[0] >= (L - 2))
sprintf(strchr(sz, 0), _("Double, Drop (since L <= T+2)"));
else if (pn[0] >= (L - 3))
sprintf(strchr(sz, 0), _("Redouble, Take (since L <= T+3)"));
else if (pn[0] >= (L - 4))
sprintf(strchr(sz, 0), _("Double, Take (since L <= T + 4)"));
else
sprintf(strchr(sz, 0), _("No Double, Take (since L > T + 4)"));}
-Øystein
ons. 12. feb. 2025 kl. 21:20 skrev Wayne Joseph <[email protected]>:
> Hi all,
>
> I saw some squiffy behaviour in the Race Formulas - Keith Count feature,
> which did not agree with XG's conclusion.
>
> Please see short video here:
> https://fy0o.short.gy/wj_cy_keith_count_bug_gnubg
>
> XGID=-ABBA-C------------e--aaa-:1:1:1:00:0:0:0:3:10
>
> GNUbg
>
> FR8AANpyAAAAAA:UQlgAAAAAAAE
>
> Chris Yep kindly cross-verified my suspicion as a bug.
>
> An excerpt of Chris' verification is below. The full thread on Facebook
> can be found here:
> https://www.facebook.com/groups/backgammonstrategy/permalink/3817038441898133/
>
> Not critical, but please can the bug be fixed?
>
> Thank you.
>
> --------
>
> >> CY
> *Yes, this error (bug) has likely existed for many years.I just checked
> all the boundary cases now. XG's doubling advice matches that given in Tom
> Keith's paper if the difference ("leader's" Keith Count minus "trailer's"
> Keith Count) is 2, 3, or 4. GNU's doubling advice matches that given in the
> paper if the difference is 3 or 4; however, if the difference is 2, GNU
> gives incorrect doubling advice (as you observed in your bearoff
> position).In addition to this error, however, GNU also doesn't truncate the
> "1/7" adjustment. According to the paper, the player on roll is supposed to
> increase his count by one seventh of the previous count, rounding down. GNU
> doesn't do any rounding. For example, if GNU's count is 36, it will
> increase this count by 36/7 (5.14) for a final count of 41.14. XG, on the
> other hand, will round the final count down to 41, as specified by the
> paper. Because GNU doesn't truncate this adjustment, additional errors
> occur (example below).In the position below, XG evaluates the Keith Counts
> as 41 to 37, so it recommends double/take. GNU, on the other hand,
> evaluates the Keith Counts as 41.14 to 37 (a difference of 4.14, which is
> more than 4), so it recommends a no double. In this position, XG is correct
> and GNU is incorrect (according to the paper).*
> [image: May be an image of text that says "19 20 21 22 23 24 13 1314 14 15
> 16 131415161718 1718 17 18 WNW 64 KG MAI Ganmon eXtreme ko extreme Ganmon
> 121110 121110987 8 12 11 10 9 654321 3 6 5 4"]
> <https://www.facebook.com/photo.php?fbid=10231708555754825&set=p.10231708555754825&type=3&__cft__[0]=AZWP4gT20yOUew61xt8Vj7zf0P-Cbjd9CCfNbyy7VFEWOE-6qQ5wPtr21YFqKUtQUOYGhET785qp1dmj4MxJLXbT1wyhqYHAehqHe9QgUvqBVlZ0PhQkgzhGksZNq6DPuE7PUBvP8SFxholSKkJ5-uTW8buKTe7C7mTzbG7I5Pa2a1WOf0hpX9jUZ3X8TnYSWm5E6VxM6y8a_vXXwoNNBJc-&__tn__=R]-R>
>
>